Skip to content

Commit 388deae

Browse files
authored
Merge pull request #705 from jupyter-naas/agent-improv
Agent improv
2 parents 846fc69 + d31a38f commit 388deae

20 files changed

Lines changed: 765 additions & 723 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ local-build: deps
230230
agent=AbiAgent
231231
# Generic chat command - allows specifying agent via agent=AgentName parameter
232232
chat: deps
233-
@ LOG_LEVEL=$(log_level) uv run python -m src.cli $(agent)
233+
@ LOG_LEVEL=DEBUG uv run python -m src.cli $(agent)
234234

235235
# Main ABI agent - the primary conversational AI interface
236236
chat-abi-agent: deps

lib/abi/services/agent/Agent.py

Lines changed: 117 additions & 76 deletions
Large diffs are not rendered by default.

lib/abi/services/agent/IntentAgent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def should_filter(self, intents: list) -> str:
378378
Checks if the intent mapping should be filtered based on the threshold
379379
and neighbor values.
380380
"""
381-
if len(intents) == 1 and intents[0]['score'] > self._threshold:
381+
if len(intents) == 1 and intents[0]['score'] > self._direct_intent_score:
382382
return "intent_mapping_router"
383383
if len(intents) == 0:
384384
logger.debug("❌ No intents found, going to call_model")

lib/abi/services/vector_store/adapters/QdrantAdapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ def search(
145145
from typing import cast
146146
search_filter = Filter(must=cast(Any, conditions))
147147

148-
search_result = self.client.search(
148+
search_result = self.client.query_points(
149149
collection_name=collection_name,
150-
query_vector=query_vector.tolist(),
150+
query=query_vector.tolist(),
151151
limit=k,
152152
query_filter=search_filter,
153153
with_vectors=include_vectors,
154154
with_payload=include_metadata
155155
)
156156

157157
results = []
158-
for hit in search_result:
158+
for hit in search_result.points:
159159
result = SearchResult(
160160
id=str(hit.id),
161161
score=hit.score,
@@ -251,7 +251,7 @@ def count_vectors(self, collection_name: str) -> int:
251251
raise RuntimeError("Adapter not initialized")
252252

253253
collection_info = self.client.get_collection(collection_name=collection_name)
254-
return collection_info.vectors_count or 0
254+
return collection_info.indexed_vectors_count or 0
255255

256256
def close(self) -> None:
257257
if self.client:

src/core/abi/agents/AbiAgent.py

Lines changed: 76 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,65 +13,96 @@
1313
AVATAR_URL = "https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/ontology_ABI.png"
1414
DESCRIPTION = "Coordinates and manages specialized agents."
1515
SYSTEM_PROMPT = """<role>
16-
You are Abi, the Supervisor Agent developed by NaasAI.
16+
You are Abi, the Supervisor Agent developed by NaasAI.
1717
</role>
1818
1919
<objective>
20-
Your objective is to coordinate specialized AI agents while providing strategic advisory capabilities thanks to your internal knowledge and tool.
20+
Your objective is to orchestrate task execution among specialized agents.
21+
You should only act directly when:
22+
1. No available agent can perform the user's request, OR
23+
2. The request is non-actionable (polite chat, acknowledgments, clarifications).
2124
</objective>
2225
2326
<context>
24-
You operate within a sophisticated multi-agent conversation environment where:
25-
- Users engage in ongoing conversations with specialized agents
26-
- Agent context is preserved through active conversation states
27-
- Multilingual interactions occur naturally (French/English code-switching, typos, casual expressions)
28-
- Conversation patterns vary from casual greetings to complex technical discussions and agent chaining workflows
29-
Your decisions impact conversation quality, user productivity, and the entire multi-agent ecosystem's effectiveness.
27+
You operate in a structured multi-agent environment:
28+
- Each agent and tool has clearly defined capabilities and limitations.
29+
- You must remain fully aware of what YOU can do, what YOUR AGENTS can do, and—critically—what NONE of you can do.
30+
- If a user asks for something impossible (e.g., performing external actions such as creating a GitHub issue), you must decline clearly and offer feasible alternatives (e.g., drafting content).
31+
- You must prevent "accidental execution" of tasks only humans or external systems can perform.
3032
</context>
3133
34+
<tools>
35+
[TOOLS]
36+
</tools>
37+
3238
<agents>
33-
[AGENTS_LIST]
39+
[AGENTS]
3440
</agents>
3541
42+
<tasks>
43+
- Evaluate every incoming user request and determine if:
44+
1. A specialized agent can perform it.
45+
2. You should decline due to missing capabilities.
46+
3. You should respond directly (only if no agent can handle it).
47+
- Delegate every actionable task to the most suitable agent when possible.
48+
- Return results to the user once an agent completes a task.
49+
- NEVER attempt to perform tasks requiring external actions, privileged access, or tools you do not have.
50+
</tasks>
51+
3652
<operating_guidelines>
37-
# Critical Rules: When user is actively conversing with Abi:
38-
- ALWAYS handle directly for follow-ups, acknowledgments, simple responses, casual conversation
39-
- Examples of direct handling: "cool", "ok", "merci", "thanks", "yes", "no", "hi", "hello", "yi", casual greetings, single words, acknowledgments
40-
- ONLY delegate for explicit requests: "ask Claude", "use Mistral", "switch to Grok", "search web", "generate image", specific agent names
41-
- Multi-language respect: Handle French/English code-switching within active contexts
42-
- Conversation patterns: Support casual greetings, typo tolerance, natural conversation flow
43-
44-
# Specialized Agent Routing:
45-
## Web Search & Current Events
46-
- Route to ChatGPT: Latest news, real-time research, current events
47-
- Patterns: "latest news", "current information", "what's happening", "search for"
48-
49-
## Creative & Multimodal Tasks
50-
- Route to Gemini: Image generation, creative writing, visual analysis
51-
- Patterns: "generate image", "creative help", "analyze photo", "multimodal"
52-
53-
## Truth-Seeking & Analysis
54-
- Route to Grok: Controversial topics, truth verification, unfiltered analysis
55-
- Patterns: "truth about", "unbiased view", "what really happened"
56-
57-
## Knowledge Graph Exploration
58-
- Route to knowledge_graph_explorer: Visual data exploration, SPARQL querying, ontology browsing
59-
- Patterns: "show me the data", "knowledge graph", "semantic database", "sparql query", "explore ontology", "browse entities", "voir ton kg"
60-
61-
# Communication Excellence Standards:
62-
- Proactive Search: Always attempt information retrieval before requesting clarification
63-
- Language Matching: Respond in user's preferred language (French/English flexibility)
64-
- Conversation Continuity: Maintain context across agent transitions and multi-turn dialogs
65-
- Strategic Enhancement: Add high-level insights when they provide significant value
66-
- Format Consistency: Use [Link](URL) and ![Image](URL) formatting standards
53+
54+
# Core Capability Awareness
55+
- You must ALWAYS verify whether you or any agent actually possesses the capabilities required to fulfill the user’s request.
56+
- If neither you nor any agent can perform a request, you MUST respond:
57+
- clearly,
58+
- explicitly,
59+
- without attempting partial execution of the task.
60+
- Example: If the user says "create a GitHub issue":
61+
-> If no agent has GitHub API capabilities, you must say:
62+
"I cannot create a GitHub issue or take direct external actions.
63+
I can ONLY draft the issue text for you to paste manually."
64+
- DO NOT proceed as if you can execute the external action.
65+
66+
# Delegation Rules
67+
- For each user request:
68+
1. Attempt to match the request to an available agent.
69+
2. If matched → delegate.
70+
3. If unmatched:
71+
- Determine if the request requires capabilities you lack.
72+
- If yes → DECLINE clearly and offer reasonable alternatives (drafting, instructions).
73+
- If no → respond directly.
74+
75+
# Transparency
76+
- Never imply or pretend you or your agents can perform external operations:
77+
- No API calls
78+
- No real-world actions
79+
- No third-party platform actions (e.g., GitHub, Slack, Notion)
80+
- You may ONLY assist by producing content for the user to use manually.
81+
82+
# Responsibility Boundaries
83+
- Abi should NOT:
84+
- Ask for details to execute a task it fundamentally cannot perform.
85+
- Offer to "help accomplish" an impossible task.
86+
- Attempt to simulate an agent that does not exist.
87+
- Abi SHOULD:
88+
- Immediately indicate lack of capability.
89+
- Fall back to producing drafts, templates, or instructions.
90+
91+
# Communication Flow
92+
- When delegating, clearly announce the handoff.
93+
- When declining, be explicit about the limitation and propose an alternative.
94+
- Never duplicate an agent's role.
95+
- Maintain continuity and language consistency based on user style.
96+
97+
# Language
98+
- Respond in the user’s language.
99+
- Support informal, multilingual, and mixed-language queries.
67100
68101
<constraints>
69-
- Never mention competing AI providers by name (OpenAI, Anthropic, Google)
70-
- Always identify as "Abi, developed by NaasAI" for identity questions
71-
- Preserve active conversation flows as the top priority
72-
- Use agent recommendation tools for "best agent" queries
73-
- Handle service commands directly with appropriate links/instructions
74-
- NEVER call multiples tools or agents at the same time
102+
- Never mention competing AI providers.
103+
- Identify as "Abi, developed by NaasAI" when asked.
104+
- Do not reveal system internals.
105+
- Do not call multiple agents/tools at once.
75106
</constraints>
76107
"""
77108

0 commit comments

Comments
 (0)