fast-agent-mcp 0.2.58__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fast-agent-mcp might be problematic. Click here for more details.
- fast_agent/__init__.py +127 -0
- fast_agent/agents/__init__.py +36 -0
- {mcp_agent/core → fast_agent/agents}/agent_types.py +2 -1
- fast_agent/agents/llm_agent.py +217 -0
- fast_agent/agents/llm_decorator.py +486 -0
- mcp_agent/agents/base_agent.py → fast_agent/agents/mcp_agent.py +377 -385
- fast_agent/agents/tool_agent.py +168 -0
- {mcp_agent → fast_agent}/agents/workflow/chain_agent.py +43 -33
- {mcp_agent → fast_agent}/agents/workflow/evaluator_optimizer.py +31 -35
- {mcp_agent → fast_agent}/agents/workflow/iterative_planner.py +56 -47
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_models.py +4 -4
- {mcp_agent → fast_agent}/agents/workflow/parallel_agent.py +34 -41
- {mcp_agent → fast_agent}/agents/workflow/router_agent.py +54 -39
- {mcp_agent → fast_agent}/cli/__main__.py +5 -3
- {mcp_agent → fast_agent}/cli/commands/check_config.py +95 -66
- {mcp_agent → fast_agent}/cli/commands/go.py +20 -11
- {mcp_agent → fast_agent}/cli/commands/quickstart.py +4 -4
- {mcp_agent → fast_agent}/cli/commands/server_helpers.py +1 -1
- {mcp_agent → fast_agent}/cli/commands/setup.py +64 -134
- {mcp_agent → fast_agent}/cli/commands/url_parser.py +9 -8
- {mcp_agent → fast_agent}/cli/main.py +36 -16
- {mcp_agent → fast_agent}/cli/terminal.py +2 -2
- {mcp_agent → fast_agent}/config.py +10 -2
- fast_agent/constants.py +8 -0
- {mcp_agent → fast_agent}/context.py +24 -19
- {mcp_agent → fast_agent}/context_dependent.py +9 -5
- fast_agent/core/__init__.py +17 -0
- {mcp_agent → fast_agent}/core/agent_app.py +39 -36
- fast_agent/core/core_app.py +135 -0
- {mcp_agent → fast_agent}/core/direct_decorators.py +12 -26
- {mcp_agent → fast_agent}/core/direct_factory.py +95 -73
- {mcp_agent → fast_agent/core}/executor/executor.py +4 -5
- {mcp_agent → fast_agent}/core/fastagent.py +32 -32
- fast_agent/core/logging/__init__.py +5 -0
- {mcp_agent → fast_agent/core}/logging/events.py +3 -3
- {mcp_agent → fast_agent/core}/logging/json_serializer.py +1 -1
- {mcp_agent → fast_agent/core}/logging/listeners.py +85 -7
- {mcp_agent → fast_agent/core}/logging/logger.py +7 -7
- {mcp_agent → fast_agent/core}/logging/transport.py +10 -11
- fast_agent/core/prompt.py +9 -0
- {mcp_agent → fast_agent}/core/validation.py +4 -4
- fast_agent/event_progress.py +61 -0
- fast_agent/history/history_exporter.py +44 -0
- {mcp_agent → fast_agent}/human_input/__init__.py +9 -12
- {mcp_agent → fast_agent}/human_input/elicitation_handler.py +26 -8
- {mcp_agent → fast_agent}/human_input/elicitation_state.py +7 -7
- {mcp_agent → fast_agent}/human_input/simple_form.py +6 -4
- {mcp_agent → fast_agent}/human_input/types.py +1 -18
- fast_agent/interfaces.py +228 -0
- fast_agent/llm/__init__.py +9 -0
- mcp_agent/llm/augmented_llm.py → fast_agent/llm/fastagent_llm.py +127 -218
- fast_agent/llm/internal/passthrough.py +137 -0
- mcp_agent/llm/augmented_llm_playback.py → fast_agent/llm/internal/playback.py +29 -25
- mcp_agent/llm/augmented_llm_silent.py → fast_agent/llm/internal/silent.py +10 -17
- fast_agent/llm/internal/slow.py +38 -0
- {mcp_agent → fast_agent}/llm/memory.py +40 -30
- {mcp_agent → fast_agent}/llm/model_database.py +35 -2
- {mcp_agent → fast_agent}/llm/model_factory.py +103 -77
- fast_agent/llm/model_info.py +126 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/anthropic_utils.py +7 -7
- fast_agent/llm/provider/anthropic/llm_anthropic.py +603 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/multipart_converter_anthropic.py +79 -86
- {mcp_agent/llm/providers → fast_agent/llm/provider/bedrock}/bedrock_utils.py +3 -1
- mcp_agent/llm/providers/augmented_llm_bedrock.py → fast_agent/llm/provider/bedrock/llm_bedrock.py +833 -717
- {mcp_agent/llm/providers → fast_agent/llm/provider/google}/google_converter.py +66 -14
- fast_agent/llm/provider/google/llm_google_native.py +431 -0
- mcp_agent/llm/providers/augmented_llm_aliyun.py → fast_agent/llm/provider/openai/llm_aliyun.py +6 -7
- mcp_agent/llm/providers/augmented_llm_azure.py → fast_agent/llm/provider/openai/llm_azure.py +4 -4
- mcp_agent/llm/providers/augmented_llm_deepseek.py → fast_agent/llm/provider/openai/llm_deepseek.py +10 -11
- mcp_agent/llm/providers/augmented_llm_generic.py → fast_agent/llm/provider/openai/llm_generic.py +4 -4
- mcp_agent/llm/providers/augmented_llm_google_oai.py → fast_agent/llm/provider/openai/llm_google_oai.py +4 -4
- mcp_agent/llm/providers/augmented_llm_groq.py → fast_agent/llm/provider/openai/llm_groq.py +14 -16
- mcp_agent/llm/providers/augmented_llm_openai.py → fast_agent/llm/provider/openai/llm_openai.py +133 -207
- mcp_agent/llm/providers/augmented_llm_openrouter.py → fast_agent/llm/provider/openai/llm_openrouter.py +6 -6
- mcp_agent/llm/providers/augmented_llm_tensorzero_openai.py → fast_agent/llm/provider/openai/llm_tensorzero_openai.py +17 -16
- mcp_agent/llm/providers/augmented_llm_xai.py → fast_agent/llm/provider/openai/llm_xai.py +6 -6
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/multipart_converter_openai.py +125 -63
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_multipart.py +12 -12
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_utils.py +18 -16
- {mcp_agent → fast_agent}/llm/provider_key_manager.py +2 -2
- {mcp_agent → fast_agent}/llm/provider_types.py +2 -0
- {mcp_agent → fast_agent}/llm/sampling_converter.py +15 -12
- {mcp_agent → fast_agent}/llm/usage_tracking.py +23 -5
- fast_agent/mcp/__init__.py +43 -0
- {mcp_agent → fast_agent}/mcp/elicitation_factory.py +3 -3
- {mcp_agent → fast_agent}/mcp/elicitation_handlers.py +19 -10
- {mcp_agent → fast_agent}/mcp/gen_client.py +3 -3
- fast_agent/mcp/helpers/__init__.py +36 -0
- fast_agent/mcp/helpers/content_helpers.py +183 -0
- {mcp_agent → fast_agent}/mcp/helpers/server_config_helpers.py +8 -8
- {mcp_agent → fast_agent}/mcp/hf_auth.py +25 -23
- fast_agent/mcp/interfaces.py +93 -0
- {mcp_agent → fast_agent}/mcp/logger_textio.py +4 -4
- {mcp_agent → fast_agent}/mcp/mcp_agent_client_session.py +49 -44
- {mcp_agent → fast_agent}/mcp/mcp_aggregator.py +66 -115
- {mcp_agent → fast_agent}/mcp/mcp_connection_manager.py +16 -23
- {mcp_agent/core → fast_agent/mcp}/mcp_content.py +23 -15
- {mcp_agent → fast_agent}/mcp/mime_utils.py +39 -0
- fast_agent/mcp/prompt.py +159 -0
- mcp_agent/mcp/prompt_message_multipart.py → fast_agent/mcp/prompt_message_extended.py +27 -20
- {mcp_agent → fast_agent}/mcp/prompt_render.py +21 -19
- {mcp_agent → fast_agent}/mcp/prompt_serialization.py +46 -46
- fast_agent/mcp/prompts/__main__.py +7 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_helpers.py +31 -30
- {mcp_agent → fast_agent}/mcp/prompts/prompt_load.py +8 -8
- {mcp_agent → fast_agent}/mcp/prompts/prompt_server.py +11 -19
- {mcp_agent → fast_agent}/mcp/prompts/prompt_template.py +18 -18
- {mcp_agent → fast_agent}/mcp/resource_utils.py +1 -1
- {mcp_agent → fast_agent}/mcp/sampling.py +31 -26
- {mcp_agent/mcp_server → fast_agent/mcp/server}/__init__.py +1 -1
- {mcp_agent/mcp_server → fast_agent/mcp/server}/agent_server.py +5 -6
- fast_agent/mcp/ui_agent.py +48 -0
- fast_agent/mcp/ui_mixin.py +209 -0
- fast_agent/mcp_server_registry.py +90 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis-campaign.py +5 -4
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/forms_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character_handler.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/tool_call.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_one.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_two.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-eval.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-imp.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/tensorzero/agent.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/tensorzero/image_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/tensorzero/simple_agent.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/chaining.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/evaluator.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/human_input.py +5 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/orchestrator.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/parallel.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/workflows/router.py +5 -2
- fast_agent/resources/setup/.gitignore +24 -0
- fast_agent/resources/setup/agent.py +18 -0
- fast_agent/resources/setup/fastagent.config.yaml +44 -0
- fast_agent/resources/setup/fastagent.secrets.yaml.example +38 -0
- fast_agent/tools/elicitation.py +369 -0
- fast_agent/types/__init__.py +32 -0
- fast_agent/types/llm_stop_reason.py +77 -0
- fast_agent/ui/__init__.py +38 -0
- fast_agent/ui/console_display.py +1005 -0
- {mcp_agent/human_input → fast_agent/ui}/elicitation_form.py +17 -12
- mcp_agent/human_input/elicitation_forms.py → fast_agent/ui/elicitation_style.py +1 -1
- {mcp_agent/core → fast_agent/ui}/enhanced_prompt.py +96 -25
- {mcp_agent/core → fast_agent/ui}/interactive_prompt.py +330 -125
- fast_agent/ui/mcp_ui_utils.py +224 -0
- {mcp_agent → fast_agent/ui}/progress_display.py +2 -2
- {mcp_agent/logging → fast_agent/ui}/rich_progress.py +4 -4
- {mcp_agent/core → fast_agent/ui}/usage_display.py +3 -8
- {fast_agent_mcp-0.2.58.dist-info → fast_agent_mcp-0.3.0.dist-info}/METADATA +7 -7
- fast_agent_mcp-0.3.0.dist-info/RECORD +202 -0
- fast_agent_mcp-0.3.0.dist-info/entry_points.txt +5 -0
- fast_agent_mcp-0.2.58.dist-info/RECORD +0 -193
- fast_agent_mcp-0.2.58.dist-info/entry_points.txt +0 -6
- mcp_agent/__init__.py +0 -114
- mcp_agent/agents/agent.py +0 -92
- mcp_agent/agents/workflow/__init__.py +0 -1
- mcp_agent/agents/workflow/orchestrator_agent.py +0 -597
- mcp_agent/app.py +0 -175
- mcp_agent/core/__init__.py +0 -26
- mcp_agent/core/prompt.py +0 -191
- mcp_agent/event_progress.py +0 -134
- mcp_agent/human_input/handler.py +0 -81
- mcp_agent/llm/__init__.py +0 -2
- mcp_agent/llm/augmented_llm_passthrough.py +0 -232
- mcp_agent/llm/augmented_llm_slow.py +0 -53
- mcp_agent/llm/providers/__init__.py +0 -8
- mcp_agent/llm/providers/augmented_llm_anthropic.py +0 -718
- mcp_agent/llm/providers/augmented_llm_google_native.py +0 -496
- mcp_agent/llm/providers/sampling_converter_anthropic.py +0 -57
- mcp_agent/llm/providers/sampling_converter_openai.py +0 -26
- mcp_agent/llm/sampling_format_converter.py +0 -37
- mcp_agent/logging/__init__.py +0 -0
- mcp_agent/mcp/__init__.py +0 -50
- mcp_agent/mcp/helpers/__init__.py +0 -25
- mcp_agent/mcp/helpers/content_helpers.py +0 -187
- mcp_agent/mcp/interfaces.py +0 -266
- mcp_agent/mcp/prompts/__init__.py +0 -0
- mcp_agent/mcp/prompts/__main__.py +0 -10
- mcp_agent/mcp_server_registry.py +0 -343
- mcp_agent/tools/tool_definition.py +0 -14
- mcp_agent/ui/console_display.py +0 -790
- mcp_agent/ui/console_display_legacy.py +0 -401
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_prompts.py +0 -0
- {mcp_agent/agents → fast_agent/cli}/__init__.py +0 -0
- {mcp_agent → fast_agent}/cli/constants.py +0 -0
- {mcp_agent → fast_agent}/core/error_handling.py +0 -0
- {mcp_agent → fast_agent}/core/exceptions.py +0 -0
- {mcp_agent/cli → fast_agent/core/executor}/__init__.py +0 -0
- {mcp_agent → fast_agent/core}/executor/task_registry.py +0 -0
- {mcp_agent → fast_agent/core}/executor/workflow_signal.py +0 -0
- {mcp_agent → fast_agent}/human_input/form_fields.py +0 -0
- {mcp_agent → fast_agent}/llm/prompt_utils.py +0 -0
- {mcp_agent/core → fast_agent/llm}/request_params.py +0 -0
- {mcp_agent → fast_agent}/mcp/common.py +0 -0
- {mcp_agent/executor → fast_agent/mcp/prompts}/__init__.py +0 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_constants.py +0 -0
- {mcp_agent → fast_agent}/py.typed +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_account_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_forms_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_game_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/researcher/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/.env.sample +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/Makefile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/README.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/clam.jpg +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/crab.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/shrimp.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/docker-compose.yml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/Dockerfile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/entrypoint.sh +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/mcp_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/pyproject.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_schema.json +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_template.minijinja +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/tensorzero.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/graded_report.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.txt +0 -0
- {mcp_agent → fast_agent/ui}/console.py +0 -0
- {mcp_agent/core → fast_agent/ui}/mermaid_utils.py +0 -0
- {fast_agent_mcp-0.2.58.dist-info → fast_agent_mcp-0.3.0.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.58.dist-info → fast_agent_mcp-0.3.0.dist-info}/licenses/LICENSE +0 -0
fast_agent/__init__.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""fast-agent - An MCP native agent application framework"""
|
|
2
|
+
|
|
3
|
+
# Configuration and settings (safe - pure Pydantic models)
|
|
4
|
+
from fast_agent.config import (
|
|
5
|
+
AnthropicSettings,
|
|
6
|
+
AzureSettings,
|
|
7
|
+
BedrockSettings,
|
|
8
|
+
DeepSeekSettings,
|
|
9
|
+
GenericSettings,
|
|
10
|
+
GoogleSettings,
|
|
11
|
+
GroqSettings,
|
|
12
|
+
HuggingFaceSettings,
|
|
13
|
+
LoggerSettings,
|
|
14
|
+
MCPElicitationSettings,
|
|
15
|
+
MCPRootSettings,
|
|
16
|
+
MCPSamplingSettings,
|
|
17
|
+
MCPServerAuthSettings,
|
|
18
|
+
MCPServerSettings,
|
|
19
|
+
MCPSettings,
|
|
20
|
+
OpenAISettings,
|
|
21
|
+
OpenRouterSettings,
|
|
22
|
+
OpenTelemetrySettings,
|
|
23
|
+
Settings,
|
|
24
|
+
TensorZeroSettings,
|
|
25
|
+
XAISettings,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Type definitions and enums (safe - no dependencies)
|
|
29
|
+
from fast_agent.types import LlmStopReason, RequestParams
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def __getattr__(name: str):
|
|
33
|
+
"""Lazy import heavy modules to avoid circular imports during package initialization."""
|
|
34
|
+
if name == "Core":
|
|
35
|
+
from fast_agent.core import Core
|
|
36
|
+
|
|
37
|
+
return Core
|
|
38
|
+
elif name == "Context":
|
|
39
|
+
from fast_agent.context import Context
|
|
40
|
+
|
|
41
|
+
return Context
|
|
42
|
+
elif name == "ContextDependent":
|
|
43
|
+
from fast_agent.context_dependent import ContextDependent
|
|
44
|
+
|
|
45
|
+
return ContextDependent
|
|
46
|
+
elif name == "ServerRegistry":
|
|
47
|
+
from fast_agent.mcp_server_registry import ServerRegistry
|
|
48
|
+
|
|
49
|
+
return ServerRegistry
|
|
50
|
+
elif name == "ProgressAction":
|
|
51
|
+
from fast_agent.event_progress import ProgressAction
|
|
52
|
+
|
|
53
|
+
return ProgressAction
|
|
54
|
+
elif name == "ProgressEvent":
|
|
55
|
+
from fast_agent.event_progress import ProgressEvent
|
|
56
|
+
|
|
57
|
+
return ProgressEvent
|
|
58
|
+
elif name == "ToolAgentSynchronous":
|
|
59
|
+
from fast_agent.agents.tool_agent import ToolAgent
|
|
60
|
+
|
|
61
|
+
return ToolAgent
|
|
62
|
+
elif name == "LlmAgent":
|
|
63
|
+
from fast_agent.agents.llm_agent import LlmAgent
|
|
64
|
+
|
|
65
|
+
return LlmAgent
|
|
66
|
+
elif name == "LlmDecorator":
|
|
67
|
+
from fast_agent.agents.llm_decorator import LlmDecorator
|
|
68
|
+
|
|
69
|
+
return LlmDecorator
|
|
70
|
+
elif name == "ToolAgent":
|
|
71
|
+
from fast_agent.agents.tool_agent import ToolAgent
|
|
72
|
+
|
|
73
|
+
return ToolAgent
|
|
74
|
+
elif name == "McpAgent":
|
|
75
|
+
from fast_agent.agents.mcp_agent import McpAgent
|
|
76
|
+
|
|
77
|
+
return McpAgent
|
|
78
|
+
elif name == "FastAgent":
|
|
79
|
+
from fast_agent.core.fastagent import FastAgent
|
|
80
|
+
|
|
81
|
+
return FastAgent
|
|
82
|
+
else:
|
|
83
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
__all__ = [
|
|
87
|
+
# Core fast-agent components (lazy loaded)
|
|
88
|
+
"Core",
|
|
89
|
+
"Context",
|
|
90
|
+
"ContextDependent",
|
|
91
|
+
"ServerRegistry",
|
|
92
|
+
# Configuration and settings (eagerly loaded)
|
|
93
|
+
"Settings",
|
|
94
|
+
"MCPSettings",
|
|
95
|
+
"MCPServerSettings",
|
|
96
|
+
"MCPServerAuthSettings",
|
|
97
|
+
"MCPSamplingSettings",
|
|
98
|
+
"MCPElicitationSettings",
|
|
99
|
+
"MCPRootSettings",
|
|
100
|
+
"AnthropicSettings",
|
|
101
|
+
"OpenAISettings",
|
|
102
|
+
"DeepSeekSettings",
|
|
103
|
+
"GoogleSettings",
|
|
104
|
+
"XAISettings",
|
|
105
|
+
"GenericSettings",
|
|
106
|
+
"OpenRouterSettings",
|
|
107
|
+
"AzureSettings",
|
|
108
|
+
"GroqSettings",
|
|
109
|
+
"OpenTelemetrySettings",
|
|
110
|
+
"TensorZeroSettings",
|
|
111
|
+
"BedrockSettings",
|
|
112
|
+
"HuggingFaceSettings",
|
|
113
|
+
"LoggerSettings",
|
|
114
|
+
# Progress and event tracking (lazy loaded)
|
|
115
|
+
"ProgressAction",
|
|
116
|
+
"ProgressEvent",
|
|
117
|
+
# Type definitions and enums (eagerly loaded)
|
|
118
|
+
"LlmStopReason",
|
|
119
|
+
"RequestParams",
|
|
120
|
+
# Agents (lazy loaded)
|
|
121
|
+
"ToolAgentSynchronous",
|
|
122
|
+
"LlmAgent",
|
|
123
|
+
"LlmDecorator",
|
|
124
|
+
"ToolAgent",
|
|
125
|
+
"McpAgent",
|
|
126
|
+
"FastAgent",
|
|
127
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Fast Agent - Agent implementations and workflow patterns.
|
|
3
|
+
|
|
4
|
+
This module exports all agent classes from the fast_agent.agents package,
|
|
5
|
+
providing a single import point for both core agents and workflow agents.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Core agents
|
|
9
|
+
from fast_agent.agents.agent_types import AgentConfig
|
|
10
|
+
from fast_agent.agents.llm_agent import LlmAgent
|
|
11
|
+
from fast_agent.agents.llm_decorator import LlmDecorator
|
|
12
|
+
from fast_agent.agents.mcp_agent import McpAgent
|
|
13
|
+
from fast_agent.agents.tool_agent import ToolAgent
|
|
14
|
+
|
|
15
|
+
# Workflow agents
|
|
16
|
+
from fast_agent.agents.workflow.chain_agent import ChainAgent
|
|
17
|
+
from fast_agent.agents.workflow.evaluator_optimizer import EvaluatorOptimizerAgent
|
|
18
|
+
from fast_agent.agents.workflow.iterative_planner import IterativePlanner
|
|
19
|
+
from fast_agent.agents.workflow.parallel_agent import ParallelAgent
|
|
20
|
+
from fast_agent.agents.workflow.router_agent import RouterAgent
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
# Core agents
|
|
24
|
+
"LlmAgent",
|
|
25
|
+
"LlmDecorator",
|
|
26
|
+
"ToolAgent",
|
|
27
|
+
"McpAgent",
|
|
28
|
+
# Workflow agents
|
|
29
|
+
"ChainAgent",
|
|
30
|
+
"EvaluatorOptimizerAgent",
|
|
31
|
+
"IterativePlanner",
|
|
32
|
+
"ParallelAgent",
|
|
33
|
+
"RouterAgent",
|
|
34
|
+
# Types
|
|
35
|
+
"AgentConfig",
|
|
36
|
+
]
|
|
@@ -9,12 +9,13 @@ from typing import Dict, List, Optional
|
|
|
9
9
|
from mcp.client.session import ElicitationFnT
|
|
10
10
|
|
|
11
11
|
# Forward imports to avoid circular dependencies
|
|
12
|
-
from
|
|
12
|
+
from fast_agent.types import RequestParams
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class AgentType(Enum):
|
|
16
16
|
"""Enumeration of supported agent types."""
|
|
17
17
|
|
|
18
|
+
LLM = "llm" # simple llm delegator
|
|
18
19
|
BASIC = "agent"
|
|
19
20
|
CUSTOM = "custom"
|
|
20
21
|
ORCHESTRATOR = "orchestrator"
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"""
|
|
2
|
+
LLM Agent class that adds interaction behaviors to LlmDecorator.
|
|
3
|
+
|
|
4
|
+
This class extends LlmDecorator with LLM-specific interaction behaviors including:
|
|
5
|
+
- UI display methods for messages, tools, and prompts
|
|
6
|
+
- Stop reason handling
|
|
7
|
+
- Tool call tracking
|
|
8
|
+
- Chat display integration
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from typing import List, Optional, Tuple
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from a2a.types import AgentCapabilities # type: ignore
|
|
15
|
+
except Exception: # pragma: no cover - optional dependency fallback
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class AgentCapabilities: # minimal fallback
|
|
20
|
+
streaming: bool = False
|
|
21
|
+
push_notifications: bool = False
|
|
22
|
+
state_transition_history: bool = False
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from mcp import Tool
|
|
26
|
+
from rich.text import Text
|
|
27
|
+
|
|
28
|
+
from fast_agent.agents.agent_types import AgentConfig
|
|
29
|
+
from fast_agent.agents.llm_decorator import LlmDecorator, ModelT
|
|
30
|
+
from fast_agent.context import Context
|
|
31
|
+
from fast_agent.types import PromptMessageExtended, RequestParams
|
|
32
|
+
from fast_agent.types.llm_stop_reason import LlmStopReason
|
|
33
|
+
from fast_agent.ui.console_display import ConsoleDisplay
|
|
34
|
+
|
|
35
|
+
# TODO -- decide what to do with type safety for model/chat_turn()
|
|
36
|
+
|
|
37
|
+
DEFAULT_CAPABILITIES = AgentCapabilities(
|
|
38
|
+
streaming=False, push_notifications=False, state_transition_history=False
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class LlmAgent(LlmDecorator):
|
|
43
|
+
"""
|
|
44
|
+
An LLM agent that adds interaction behaviors to the base LlmDecorator.
|
|
45
|
+
|
|
46
|
+
This class provides LLM-specific functionality including UI display methods,
|
|
47
|
+
tool call tracking, and chat interaction patterns while delegating core
|
|
48
|
+
LLM operations to the attached AugmentedLLMProtocol.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
config: AgentConfig,
|
|
54
|
+
context: Context | None = None,
|
|
55
|
+
) -> None:
|
|
56
|
+
super().__init__(config=config, context=context)
|
|
57
|
+
|
|
58
|
+
# Initialize display component
|
|
59
|
+
self.display = ConsoleDisplay(config=self._context.config if self._context else None)
|
|
60
|
+
|
|
61
|
+
async def show_assistant_message(
|
|
62
|
+
self,
|
|
63
|
+
message: PromptMessageExtended,
|
|
64
|
+
bottom_items: List[str] | None = None,
|
|
65
|
+
highlight_items: str | List[str] | None = None,
|
|
66
|
+
max_item_length: int | None = None,
|
|
67
|
+
name: str | None = None,
|
|
68
|
+
model: str | None = None,
|
|
69
|
+
additional_message: Optional[Text] = None,
|
|
70
|
+
) -> None:
|
|
71
|
+
"""Display an assistant message with appropriate styling based on stop reason.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
message: The message to display
|
|
75
|
+
bottom_items: Optional items for bottom bar (e.g., servers, destinations)
|
|
76
|
+
highlight_items: Items to highlight in bottom bar
|
|
77
|
+
max_item_length: Max length for bottom items
|
|
78
|
+
name: Optional agent name to display
|
|
79
|
+
model: Optional model name to display
|
|
80
|
+
additional_message: Optional additional message to display
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
# Determine display content based on stop reason if not provided
|
|
84
|
+
if additional_message is None:
|
|
85
|
+
# Generate additional message based on stop reason
|
|
86
|
+
match message.stop_reason:
|
|
87
|
+
case LlmStopReason.END_TURN:
|
|
88
|
+
# No additional message needed for normal end turn
|
|
89
|
+
additional_message_text = None
|
|
90
|
+
|
|
91
|
+
case LlmStopReason.MAX_TOKENS:
|
|
92
|
+
additional_message_text = Text(
|
|
93
|
+
"\n\nMaximum output tokens reached - generation stopped.",
|
|
94
|
+
style="dim red italic",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
case LlmStopReason.SAFETY:
|
|
98
|
+
additional_message_text = Text(
|
|
99
|
+
"\n\nContent filter activated - generation stopped.", style="dim red italic"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
case LlmStopReason.PAUSE:
|
|
103
|
+
additional_message_text = Text(
|
|
104
|
+
"\n\nLLM has requested a pause.", style="dim green italic"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
case LlmStopReason.STOP_SEQUENCE:
|
|
108
|
+
additional_message_text = Text(
|
|
109
|
+
"\n\nStop Sequence activated - generation stopped.", style="dim red italic"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
case LlmStopReason.TOOL_USE:
|
|
113
|
+
if None is message.last_text():
|
|
114
|
+
additional_message_text = Text(
|
|
115
|
+
"The assistant requested tool calls", style="dim green italic"
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
additional_message_text = None
|
|
119
|
+
|
|
120
|
+
case _:
|
|
121
|
+
if message.stop_reason:
|
|
122
|
+
additional_message_text = Text(
|
|
123
|
+
f"\n\nGeneration stopped for an unhandled reason ({message.stop_reason})",
|
|
124
|
+
style="dim red italic",
|
|
125
|
+
)
|
|
126
|
+
else:
|
|
127
|
+
additional_message_text = None
|
|
128
|
+
else:
|
|
129
|
+
# Use provided additional message
|
|
130
|
+
additional_message_text = (
|
|
131
|
+
additional_message if isinstance(additional_message, Text) else None
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
message_text = message.last_text() or ""
|
|
135
|
+
|
|
136
|
+
# Use provided name/model or fall back to defaults
|
|
137
|
+
display_name = name if name is not None else self.name
|
|
138
|
+
display_model = model if model is not None else (self.llm.model_name if self._llm else None)
|
|
139
|
+
|
|
140
|
+
await self.display.show_assistant_message(
|
|
141
|
+
message_text,
|
|
142
|
+
bottom_items=bottom_items,
|
|
143
|
+
highlight_items=highlight_items,
|
|
144
|
+
max_item_length=max_item_length,
|
|
145
|
+
name=display_name,
|
|
146
|
+
model=display_model,
|
|
147
|
+
additional_message=additional_message_text,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def show_user_message(self, message: PromptMessageExtended) -> None:
|
|
151
|
+
"""Display a user message in a formatted panel."""
|
|
152
|
+
model = self.llm.model_name
|
|
153
|
+
chat_turn = self._llm.chat_turn()
|
|
154
|
+
self.display.show_user_message(message.last_text() or "", model, chat_turn, name=self.name)
|
|
155
|
+
|
|
156
|
+
async def generate_impl(
|
|
157
|
+
self,
|
|
158
|
+
messages: List[PromptMessageExtended],
|
|
159
|
+
request_params: RequestParams | None = None,
|
|
160
|
+
tools: List[Tool] | None = None,
|
|
161
|
+
) -> PromptMessageExtended:
|
|
162
|
+
"""
|
|
163
|
+
Enhanced generate implementation that resets tool call tracking.
|
|
164
|
+
Messages are already normalized to List[PromptMessageExtended].
|
|
165
|
+
"""
|
|
166
|
+
if "user" == messages[-1].role:
|
|
167
|
+
self.show_user_message(message=messages[-1])
|
|
168
|
+
|
|
169
|
+
# TODO -- we should merge the request parameters here with the LLM defaults?
|
|
170
|
+
# TODO - manage error catch, recovery, pause
|
|
171
|
+
result = await super().generate_impl(messages, request_params, tools)
|
|
172
|
+
|
|
173
|
+
await self.show_assistant_message(result)
|
|
174
|
+
return result
|
|
175
|
+
|
|
176
|
+
async def structured_impl(
|
|
177
|
+
self,
|
|
178
|
+
messages: List[PromptMessageExtended],
|
|
179
|
+
model: type[ModelT],
|
|
180
|
+
request_params: RequestParams | None = None,
|
|
181
|
+
) -> Tuple[ModelT | None, PromptMessageExtended]:
|
|
182
|
+
if "user" == messages[-1].role:
|
|
183
|
+
self.show_user_message(message=messages[-1])
|
|
184
|
+
|
|
185
|
+
result, message = await super().structured_impl(messages, model, request_params)
|
|
186
|
+
await self.show_assistant_message(message=message)
|
|
187
|
+
return result, message
|
|
188
|
+
|
|
189
|
+
# async def show_prompt_loaded(
|
|
190
|
+
# self,
|
|
191
|
+
# prompt_name: str,
|
|
192
|
+
# description: Optional[str] = None,
|
|
193
|
+
# message_count: int = 0,
|
|
194
|
+
# arguments: Optional[dict[str, str]] = None,
|
|
195
|
+
# ) -> None:
|
|
196
|
+
# """
|
|
197
|
+
# Display information about a loaded prompt template.
|
|
198
|
+
|
|
199
|
+
# Args:
|
|
200
|
+
# prompt_name: The name of the prompt
|
|
201
|
+
# description: Optional description of the prompt
|
|
202
|
+
# message_count: Number of messages in the prompt
|
|
203
|
+
# arguments: Optional dictionary of arguments passed to the prompt
|
|
204
|
+
# """
|
|
205
|
+
# # Get aggregator from attached LLM if available
|
|
206
|
+
# aggregator = None
|
|
207
|
+
# if self._llm and hasattr(self._llm, "aggregator"):
|
|
208
|
+
# aggregator = self._llm.aggregator
|
|
209
|
+
|
|
210
|
+
# await self.display.show_prompt_loaded(
|
|
211
|
+
# prompt_name=prompt_name,
|
|
212
|
+
# description=description,
|
|
213
|
+
# message_count=message_count,
|
|
214
|
+
# agent_name=self.name,
|
|
215
|
+
# aggregator=aggregator,
|
|
216
|
+
# arguments=arguments,
|
|
217
|
+
# )
|