Skip to content

Commit 0c932f1

Browse files
committed
fix types in agent completer + version bump
1 parent 26495b4 commit 0c932f1

File tree

16 files changed

+80
-302
lines changed

16 files changed

+80
-302
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,4 @@ tests/integration/workflow/orchestrator/fastagent.jsonl
190190
fastagent.jsonl
191191
tests/integration/resources/fastagent.jsonl
192192
fastagent.jsonl
193+
tests/e2e/workflow/weather_location.txt

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fast-agent-mcp"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
description = "Define, Prompt and Test MCP enabled Agents and Workflows"
55
readme = "README.md"
66
license = { file = "LICENSE" }

src/mcp_agent/agents/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def prompt(self, default_prompt: str = "", agent_name: Optional[str] = Non
6666
agent_name_str = str(self.name)
6767

6868
# Create agent_types dictionary with just this agent
69-
agent_types = {agent_name_str: getattr(self.config, "agent_type", "Agent")}
69+
agent_types = {agent_name_str: self.agent_type}
7070

7171
# Create the interactive prompt
7272
prompt = InteractivePrompt(agent_types=agent_types)

src/mcp_agent/agents/base_agent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,18 @@ async def apply_prompt_messages(
622622
response = await self.generate(prompts, request_params)
623623
return response.first_text()
624624

625+
@property
626+
def agent_type(self) -> str:
627+
"""
628+
Return the type of this agent.
629+
630+
This is used for display purposes in the interactive prompt and other UI elements.
631+
632+
Returns:
633+
String representing the agent type
634+
"""
635+
return self.config.agent_type
636+
625637
@property
626638
def message_history(self) -> List[PromptMessageMultipart]:
627639
"""

src/mcp_agent/agents/workflow/chain_agent.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
from mcp.types import TextContent
1111

12-
from mcp_agent.agents.agent import Agent, AgentConfig
12+
from mcp_agent.agents.agent import Agent
1313
from mcp_agent.agents.base_agent import BaseAgent
14+
from mcp_agent.core.agent_types import AgentConfig, AgentType
1415
from mcp_agent.core.prompt import Prompt
1516
from mcp_agent.core.request_params import RequestParams
1617
from mcp_agent.mcp.interfaces import ModelT
@@ -22,6 +23,11 @@ class ChainAgent(BaseAgent):
2223
A chain agent that processes requests through a series of specialized agents in sequence.
2324
Passes the output of each agent to the next agent in the chain.
2425
"""
26+
27+
@property
28+
def agent_type(self) -> str:
29+
"""Return the type of this agent."""
30+
return AgentType.CHAIN.value
2531

2632
def __init__(
2733
self,

src/mcp_agent/agents/workflow/evaluator_optimizer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from mcp_agent.agents.agent import Agent
1616
from mcp_agent.agents.base_agent import BaseAgent
17+
from mcp_agent.core.agent_types import AgentType
1718
from mcp_agent.core.exceptions import AgentConfigError
1819
from mcp_agent.core.prompt import Prompt
1920
from mcp_agent.core.request_params import RequestParams
@@ -63,6 +64,11 @@ class EvaluatorOptimizerAgent(BaseAgent):
6364
for refinement, continuing until a quality threshold is reached or a maximum
6465
number of refinement cycles is completed.
6566
"""
67+
68+
@property
69+
def agent_type(self) -> str:
70+
"""Return the type of this agent."""
71+
return AgentType.EVALUATOR_OPTIMIZER.value
6672

6773
def __init__(
6874
self,

src/mcp_agent/agents/workflow/orchestrator_agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
SYNTHESIZE_PLAN_PROMPT_TEMPLATE,
2828
TASK_PROMPT_TEMPLATE,
2929
)
30-
from mcp_agent.core.agent_types import AgentConfig
30+
from mcp_agent.core.agent_types import AgentConfig, AgentType
3131
from mcp_agent.core.exceptions import AgentConfigError
3232
from mcp_agent.core.prompt import Prompt
3333
from mcp_agent.core.request_params import RequestParams
@@ -46,6 +46,11 @@ class OrchestratorAgent(BaseAgent):
4646
to specialized worker agents, synthesizing their results into a cohesive output.
4747
Supports both full planning and iterative planning modes.
4848
"""
49+
50+
@property
51+
def agent_type(self) -> str:
52+
"""Return the type of this agent."""
53+
return AgentType.ORCHESTRATOR.value
4954

5055
def __init__(
5156
self,

src/mcp_agent/agents/workflow/parallel_agent.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
from mcp.types import TextContent
55

6-
from mcp_agent.agents.agent import Agent, AgentConfig
6+
from mcp_agent.agents.agent import Agent
77
from mcp_agent.agents.base_agent import BaseAgent
8+
from mcp_agent.core.agent_types import AgentConfig, AgentType
89
from mcp_agent.core.request_params import RequestParams
910
from mcp_agent.mcp.interfaces import ModelT
1011
from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
@@ -17,6 +18,11 @@ class ParallelAgent(BaseAgent):
1718
This workflow performs both the fan-out and fan-in operations using LLMs.
1819
From the user's perspective, an input is specified and the output is returned.
1920
"""
21+
22+
@property
23+
def agent_type(self) -> str:
24+
"""Return the type of this agent."""
25+
return AgentType.PARALLEL.value
2026

2127
def __init__(
2228
self,

src/mcp_agent/agents/workflow/router_agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from mcp_agent.agents.agent import Agent
1414
from mcp_agent.agents.base_agent import BaseAgent
15-
from mcp_agent.core.agent_types import AgentConfig
15+
from mcp_agent.core.agent_types import AgentConfig, AgentType
1616
from mcp_agent.core.exceptions import AgentConfigError
1717
from mcp_agent.core.prompt import Prompt
1818
from mcp_agent.core.request_params import RequestParams
@@ -87,6 +87,11 @@ class RouterAgent(BaseAgent):
8787
A simplified router that uses an LLM to determine the best agent for a request,
8888
then dispatches the request to that agent and returns the response.
8989
"""
90+
91+
@property
92+
def agent_type(self) -> str:
93+
"""Return the type of this agent."""
94+
return AgentType.ROUTER.value
9095

9196
def __init__(
9297
self,

src/mcp_agent/core/agent_app.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,7 @@ async def interactive(self, agent: str | None = None, default_prompt: str = "")
248248
# The agent's prompt method doesn't fully support switching between agents
249249

250250
# Create agent_types dictionary mapping agent names to their types
251-
agent_types = {}
252-
for name, agent in self._agents.items():
253-
# Determine agent type if possible
254-
agent_type = "Agent" # Default type
255-
256-
# Try to get the type from the agent directly
257-
if hasattr(agent, "agent_type"):
258-
agent_type = agent.agent_type
259-
elif hasattr(agent, "config") and hasattr(agent.config, "agent_type"):
260-
agent_type = agent.config.agent_type
261-
262-
agent_types[name] = agent_type
251+
agent_types = {name: agent.agent_type for name, agent in self._agents.items()}
263252

264253
# Create the interactive prompt
265254
prompt = InteractivePrompt(agent_types=agent_types)

0 commit comments

Comments
 (0)