solace-agent-mesh 1.4.12__py3-none-any.whl → 1.5.1__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 solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agent/adk/adk_llm.txt +3 -4
- solace_agent_mesh/agent/adk/adk_llm_detail.txt +566 -0
- solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +1 -1
- solace_agent_mesh/agent/adk/callbacks.py +56 -5
- solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +3 -1
- solace_agent_mesh/agent/adk/intelligent_mcp_callbacks.py +2 -1
- solace_agent_mesh/agent/adk/mcp_content_processor.py +2 -1
- solace_agent_mesh/agent/adk/models/lite_llm.py +1 -0
- solace_agent_mesh/agent/adk/models/models_llm.txt +1 -2
- solace_agent_mesh/agent/adk/runner.py +3 -1
- solace_agent_mesh/agent/adk/services.py +4 -1
- solace_agent_mesh/agent/adk/setup.py +3 -1
- solace_agent_mesh/agent/adk/tool_wrapper.py +2 -2
- solace_agent_mesh/agent/agent_llm.txt +1 -1
- solace_agent_mesh/agent/agent_llm_detail.txt +1702 -0
- solace_agent_mesh/agent/protocol/event_handlers.py +4 -14
- solace_agent_mesh/agent/protocol/protocol_llm.txt +15 -2
- solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +92 -0
- solace_agent_mesh/agent/sac/app.py +3 -1
- solace_agent_mesh/agent/sac/component.py +55 -22
- solace_agent_mesh/agent/sac/sac_llm.txt +15 -1
- solace_agent_mesh/agent/sac/sac_llm_detail.txt +200 -0
- solace_agent_mesh/agent/sac/task_execution_context.py +73 -0
- solace_agent_mesh/agent/testing/testing_llm_detail.txt +68 -0
- solace_agent_mesh/agent/tools/audio_tools.py +2 -1
- solace_agent_mesh/agent/tools/builtin_artifact_tools.py +3 -1
- solace_agent_mesh/agent/tools/builtin_data_analysis_tools.py +3 -1
- solace_agent_mesh/agent/tools/dynamic_tool.py +2 -1
- solace_agent_mesh/agent/tools/general_agent_tools.py +2 -1
- solace_agent_mesh/agent/tools/image_tools.py +2 -1
- solace_agent_mesh/agent/tools/peer_agent_tool.py +2 -1
- solace_agent_mesh/agent/tools/registry.py +3 -1
- solace_agent_mesh/agent/tools/test_tools.py +2 -1
- solace_agent_mesh/agent/tools/tools_llm.txt +148 -154
- solace_agent_mesh/agent/tools/tools_llm_detail.txt +274 -0
- solace_agent_mesh/agent/tools/web_tools.py +2 -1
- solace_agent_mesh/agent/utils/artifact_helpers.py +3 -1
- solace_agent_mesh/agent/utils/config_parser.py +3 -1
- solace_agent_mesh/agent/utils/utils_llm.txt +1 -1
- solace_agent_mesh/agent/utils/utils_llm_detail.txt +149 -0
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/{b7006a3a.73a79653.js → 032c2d61.f3d37824.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/0bcf40b7.c019ad46.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/15ba94aa.932dd2db.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2131ec11.5c7a1f6e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{2334.622a6395.js → 2334.1cf50a20.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/240a0364.7eac6021.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2e32b5e0.33f5d75b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/341393d4.0fac2613.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{3624.b524e433.js → 3624.0eaa1fd0.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/3a6c6137.f5940cfa.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3ac1795d.76654dd9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3ff0015d.2be20244.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/509e993c.4c7a1a6d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/547e15cc.2cbb060a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/55b7b518.f2b1d1ba.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5c2bd65f.e49689dd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6063ff4c.ef84f702.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/631738c7.a8b1ef8b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6a520c9d.ba015d81.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.39d5851d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6d84eae0.4a5fbf39.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6fdfefc7.99de744e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/71da7b71.804d6567.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/722f809d.965da774.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/742f027b.46c07808.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/77cf947d.64c9bd6c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8024126c.56e59919.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/81a99df0.07034dd9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/82fbfb93.139a1a1f.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{8591.d7c16be6.js → 8591.5d015485.js} +2 -2
- solace_agent_mesh/assets/docs/assets/js/{8731.49e930c2.js → 8731.6c1dbf0c.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/945fb41e.6f4cdffd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/94e8668d.b5ddb7a1.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9bb13469.dd1c9b54.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9e9d0a82.dd810042.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ab9708a8.3e6dd091.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ad71b5ed.60668e9e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/c198a0dc.8f31f867.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/c93cbaa0.eaff365e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/da0b5bad.9d369087.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/db924877.cbc66f02.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/dd817ffc.0aa9630a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/dd81e2b8.d590bc9e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/de5f4c65.e8241890.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/de915948.139b4b9c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e3d9abda.2b916f9e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e6f9706b.582a78ca.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/e92d0134.cf6d6522.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f284c35a.5766a13d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ff4d71f2.9c0297a6.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.bd3c34f3.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.18dc45dd.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +143 -0
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → components}/builtin-tools/artifact-management/index.html +7 -7
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → components}/builtin-tools/audio-tools/index.html +7 -7
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → components}/builtin-tools/data-analysis-tools/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → components}/builtin-tools/embeds/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → components}/builtin-tools/index.html +11 -11
- solace_agent_mesh/assets/docs/docs/documentation/{concepts → components}/cli/index.html +25 -25
- solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +91 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/index.html +29 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +55 -0
- solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +110 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +104 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +57 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +25 -0
- solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +59 -0
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → developing}/create-agents/index.html +113 -152
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → developing}/create-gateways/index.html +9 -9
- solace_agent_mesh/assets/docs/docs/documentation/{user-guide → developing}/creating-python-tools/index.html +12 -12
- solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +54 -0
- solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +32 -0
- solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +55 -0
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/bedrock-agents/index.html +25 -25
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/custom-agent/index.html +13 -13
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/event-mesh-gateway/index.html +11 -11
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/mcp-integration/index.html +10 -10
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/mongodb-integration/index.html +13 -13
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/rag-integration/index.html +13 -13
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/rest-gateway/index.html +10 -10
- solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +72 -0
- solace_agent_mesh/assets/docs/docs/documentation/{tutorials → developing/tutorials}/sql-database/index.html +14 -14
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +33 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +83 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +222 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +161 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +75 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +53 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +35 -100
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +41 -0
- solace_agent_mesh/assets/docs/docs/documentation/{getting-started → installing-and-configuring}/configurations/index.html +56 -50
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +25 -0
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +76 -0
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +63 -0
- solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +142 -0
- solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +100 -0
- solace_agent_mesh/assets/docs/docs/documentation/{Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html → migrations/a2a-upgrade/a2a-technical-migration-map/index.html} +10 -11
- solace_agent_mesh/assets/docs/img/solace-logo.png +0 -0
- solace_agent_mesh/assets/docs/lunr-index-1760121512891.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1760121512891.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/assets/docs/sitemap.xml +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-j1LW-wlq.js → authCallback-DwrxZE0E.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{client-B9p_nFNA.js → client-DarGQzyw.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-2nd1gbaH.js +339 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-DoKXctCM.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{vendor-CS5YMf8a.js → vendor-BKIeiHj_.js} +80 -70
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
- solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
- solace_agent_mesh/common/a2a/a2a_llm.txt +1 -1
- solace_agent_mesh/common/a2a/a2a_llm_detail.txt +193 -0
- solace_agent_mesh/common/a2a/artifact.py +2 -1
- solace_agent_mesh/common/a2a/protocol.py +3 -2
- solace_agent_mesh/common/a2a/translation.py +3 -1
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +1 -1
- solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +736 -0
- solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +23 -0
- solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +93 -15
- solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +23 -0
- solace_agent_mesh/common/common_llm.txt +24 -39
- solace_agent_mesh/common/common_llm_detail.txt +2562 -0
- solace_agent_mesh/common/data_parts.py +9 -1
- solace_agent_mesh/common/middleware/config_resolver.py +3 -1
- solace_agent_mesh/common/middleware/middleware_llm_detail.txt +185 -0
- solace_agent_mesh/common/middleware/registry.py +3 -1
- solace_agent_mesh/common/sac/sac_llm.txt +1 -1
- solace_agent_mesh/common/sac/sac_llm_detail.txt +82 -0
- solace_agent_mesh/common/sac/sam_component_base.py +2 -1
- solace_agent_mesh/common/sam_events/event_service.py +3 -2
- solace_agent_mesh/common/sam_events/sam_events_llm.txt +104 -0
- solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +115 -0
- solace_agent_mesh/common/services/employee_service.py +3 -1
- solace_agent_mesh/common/services/identity_service.py +2 -1
- solace_agent_mesh/common/services/providers/local_file_identity_service.py +2 -1
- solace_agent_mesh/common/services/services_llm.txt +57 -6
- solace_agent_mesh/common/services/services_llm_detail.txt +459 -0
- solace_agent_mesh/common/utils/artifact_utils.py +3 -1
- solace_agent_mesh/common/utils/asyncio_macos_fix.py +3 -1
- solace_agent_mesh/common/utils/embeds/converter.py +3 -1
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +1 -1
- solace_agent_mesh/common/utils/embeds/evaluators.py +2 -1
- solace_agent_mesh/common/utils/embeds/modifiers.py +3 -2
- solace_agent_mesh/common/utils/embeds/resolver.py +2 -1
- solace_agent_mesh/common/utils/initializer.py +3 -1
- solace_agent_mesh/common/utils/message_utils.py +2 -1
- solace_agent_mesh/common/utils/push_notification_auth.py +3 -2
- solace_agent_mesh/common/utils/utils_llm.txt +75 -87
- solace_agent_mesh/common/utils/utils_llm_detail.txt +572 -0
- solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +101 -0
- solace_agent_mesh/core_a2a/service.py +2 -2
- solace_agent_mesh/gateway/base/app.py +3 -2
- solace_agent_mesh/gateway/base/base_llm.txt +1 -1
- solace_agent_mesh/gateway/base/base_llm_detail.txt +235 -0
- solace_agent_mesh/gateway/base/component.py +3 -1
- solace_agent_mesh/gateway/base/task_context.py +2 -1
- solace_agent_mesh/gateway/gateway_llm.txt +242 -235
- solace_agent_mesh/gateway/gateway_llm_detail.txt +3885 -0
- solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +295 -0
- solace_agent_mesh/gateway/http_sse/alembic/env.py +10 -1
- solace_agent_mesh/gateway/http_sse/alembic/versions/20251006_98882922fa59_add_tasks_events_feedback_chat_tasks.py +190 -0
- solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +155 -0
- solace_agent_mesh/gateway/http_sse/alembic.ini +1 -1
- solace_agent_mesh/gateway/http_sse/app.py +150 -3
- solace_agent_mesh/gateway/http_sse/component.py +372 -61
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +46 -6
- solace_agent_mesh/gateway/http_sse/components/task_logger_forwarder.py +109 -0
- solace_agent_mesh/gateway/http_sse/components/visualization_forwarder_component.py +4 -2
- solace_agent_mesh/gateway/http_sse/dependencies.py +119 -27
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +172 -172
- solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +3278 -0
- solace_agent_mesh/gateway/http_sse/main.py +149 -42
- solace_agent_mesh/gateway/http_sse/repository/__init__.py +3 -12
- solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +103 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/__init__.py +5 -3
- solace_agent_mesh/gateway/http_sse/repository/entities/chat_task.py +75 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +263 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/feedback.py +20 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/session_history.py +0 -16
- solace_agent_mesh/gateway/http_sse/repository/entities/task.py +25 -0
- solace_agent_mesh/gateway/http_sse/repository/entities/task_event.py +21 -0
- solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +81 -0
- solace_agent_mesh/gateway/http_sse/repository/interfaces.py +73 -18
- solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +9 -5
- solace_agent_mesh/gateway/http_sse/repository/models/chat_task_model.py +31 -0
- solace_agent_mesh/gateway/http_sse/repository/models/feedback_model.py +21 -0
- solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +266 -0
- solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +3 -3
- solace_agent_mesh/gateway/http_sse/repository/models/task_event_model.py +25 -0
- solace_agent_mesh/gateway/http_sse/repository/models/task_model.py +32 -0
- solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +340 -0
- solace_agent_mesh/gateway/http_sse/repository/session_repository.py +4 -53
- solace_agent_mesh/gateway/http_sse/repository/task_repository.py +173 -0
- solace_agent_mesh/gateway/http_sse/routers/agent_cards.py +3 -2
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +3 -3
- solace_agent_mesh/gateway/http_sse/routers/auth.py +3 -1
- solace_agent_mesh/gateway/http_sse/routers/config.py +29 -6
- solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +346 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/__init__.py +3 -3
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +83 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +2 -10
- solace_agent_mesh/gateway/http_sse/routers/dto/requests/task_requests.py +58 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/__init__.py +5 -3
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +107 -0
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +1 -15
- solace_agent_mesh/gateway/http_sse/routers/dto/responses/task_responses.py +30 -0
- solace_agent_mesh/gateway/http_sse/routers/feedback.py +37 -0
- solace_agent_mesh/gateway/http_sse/routers/people.py +3 -1
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +255 -204
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +223 -41
- solace_agent_mesh/gateway/http_sse/routers/sse.py +3 -2
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +170 -43
- solace_agent_mesh/gateway/http_sse/routers/users.py +3 -1
- solace_agent_mesh/gateway/http_sse/routers/visualization.py +2 -1
- solace_agent_mesh/gateway/http_sse/services/agent_card_service.py +3 -1
- solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +273 -0
- solace_agent_mesh/gateway/http_sse/services/feedback_service.py +242 -0
- solace_agent_mesh/gateway/http_sse/services/people_service.py +2 -82
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +177 -13
- solace_agent_mesh/gateway/http_sse/services/session_service.py +154 -85
- solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +318 -0
- solace_agent_mesh/gateway/http_sse/services/task_service.py +3 -2
- solace_agent_mesh/gateway/http_sse/session_manager.py +2 -1
- solace_agent_mesh/gateway/http_sse/shared/exception_handlers.py +25 -14
- solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +285 -0
- solace_agent_mesh/gateway/http_sse/shared/types.py +7 -0
- solace_agent_mesh/gateway/http_sse/sse_event_buffer.py +2 -1
- solace_agent_mesh/gateway/http_sse/sse_manager.py +2 -2
- solace_agent_mesh/gateway/http_sse/utils/__init__.py +1 -0
- solace_agent_mesh/gateway/http_sse/utils/stim_utils.py +32 -0
- solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +47 -0
- solace_agent_mesh/solace_agent_mesh_llm.txt +1 -1
- solace_agent_mesh/solace_agent_mesh_llm_detail.txt +8599 -0
- solace_agent_mesh/templates/gateway_app_template.py +4 -2
- solace_agent_mesh/templates/gateway_component_template.py +3 -1
- solace_agent_mesh/templates/logging_config_template.ini +22 -45
- solace_agent_mesh/templates/plugin_tools_template.py +2 -2
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.1.dist-info}/METADATA +2 -2
- solace_agent_mesh-1.5.1.dist-info/RECORD +504 -0
- solace_agent_mesh/agent/adk/invocation_monitor.py +0 -295
- solace_agent_mesh/assets/docs/assets/images/sac-flows-80d5b603c6aafd33e87945680ce0abf3.png +0 -0
- solace_agent_mesh/assets/docs/assets/images/sac_parts_of_a_component-cb3d0424b1d0c17734c5435cca6b4082.png +0 -0
- solace_agent_mesh/assets/docs/assets/js/04989206.a248f00c.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/0e682baa.d54b8668.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/1023fc19.8a8a9309.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/1523c6b4.2645ef68.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/166ab619.e27886d9.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/1c6e87d2.e056b7e0.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/21ceee5f.3bf39250.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/2a9cab12.2afaee76.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/332e10b5.f7629851.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/3d406171.5560fdf9.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.508ae8db.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/442a8107.b5c2532a.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/453a82a6.3c6bb61d.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/483cef9a.4736f2d8.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/4c2787c2.c1290a40.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/55f47984.bcd00a86.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/5b4258a4.fdfd2325.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/664b740a.ba305a89.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/75384d09.c19e8b51.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/768e31b0.9abcdc48.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/85387663.be2bc838.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/945fb41e.16e00776.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/9a09e75d.92de8cf5.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/9eff14a2.d62aad71.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/a12a4955.25fbed32.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/a3a92b25.af35e313.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/aba87c2f.4ddf32f2.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ae0e903d.5fe5203f.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ae4415af.16cc58d3.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/bac0be12.17de4316.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/c2c06897.87cb1f47.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/c835a94d.ce21f0bf.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/cc969b05.feef7dcc.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/cd3d4052.a19e7d78.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ced92a13.fb92e7ca.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/cee5d587.47904f5e.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/d6a81ee7.829198f1.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/f284c35a.ed8dd236.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/f897a61a.126663fe.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/fbfa3e75.e144b16c.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/main.f67fc9f4.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/runtime~main.40527046.js +0 -1
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +0 -46
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/rbac-setup-guilde/index.html +0 -201
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +0 -25
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +0 -105
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +0 -144
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +0 -91
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +0 -91
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +0 -55
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +0 -111
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +0 -77
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +0 -48
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +0 -54
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +0 -45
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/litellm_models/index.html +0 -49
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +0 -76
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +0 -73
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +0 -72
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +0 -54
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +0 -69
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +0 -59
- solace_agent_mesh/assets/docs/lunr-index-1759936913198.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1759936913198.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-ChRwcV89.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-DnnE01OM.js +0 -339
- solace_agent_mesh/gateway/http_sse/repository/entities/message.py +0 -41
- solace_agent_mesh/gateway/http_sse/repository/message_repository.py +0 -84
- solace_agent_mesh/gateway/http_sse/repository/models/message_model.py +0 -45
- solace_agent_mesh-1.4.12.dist-info/RECORD +0 -448
- /solace_agent_mesh/assets/docs/assets/js/{8591.d7c16be6.js.LICENSE.txt → 8591.5d015485.js.LICENSE.txt} +0 -0
- /solace_agent_mesh/assets/docs/assets/js/{main.f67fc9f4.js.LICENSE.txt → main.bd3c34f3.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.1.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.1.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.4.12.dist-info → solace_agent_mesh-1.5.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Contains event handling logic for the A2A_ADK_HostComponent.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import logging
|
|
5
6
|
import json
|
|
6
7
|
import asyncio
|
|
7
8
|
from typing import TYPE_CHECKING, Dict, Any
|
|
8
9
|
import fnmatch
|
|
9
|
-
from solace_ai_connector.common.log import log
|
|
10
10
|
from solace_ai_connector.common.message import Message as SolaceMessage
|
|
11
11
|
from ...agent.adk.callbacks import _publish_data_part_status_update
|
|
12
12
|
from ...common.data_parts import ToolResultData
|
|
@@ -47,6 +47,7 @@ if TYPE_CHECKING:
|
|
|
47
47
|
from ..sac.component import SamAgentComponent
|
|
48
48
|
from google.adk.agents.run_config import StreamingMode
|
|
49
49
|
|
|
50
|
+
log = logging.getLogger(__name__)
|
|
50
51
|
|
|
51
52
|
def _register_peer_artifacts_in_parent_context(
|
|
52
53
|
parent_task_context: "TaskExecutionContext",
|
|
@@ -97,19 +98,6 @@ async def process_event(component, event: Event):
|
|
|
97
98
|
component.log_identifier,
|
|
98
99
|
)
|
|
99
100
|
return
|
|
100
|
-
if component.invocation_monitor:
|
|
101
|
-
component.invocation_monitor.log_message_event(
|
|
102
|
-
direction="RECEIVED",
|
|
103
|
-
topic=topic,
|
|
104
|
-
payload=message.get_payload(),
|
|
105
|
-
component_identifier=component.log_identifier,
|
|
106
|
-
)
|
|
107
|
-
else:
|
|
108
|
-
log.warning(
|
|
109
|
-
"%s InvocationMonitor not available in component for event on topic %s",
|
|
110
|
-
component.log_identifier,
|
|
111
|
-
topic,
|
|
112
|
-
)
|
|
113
101
|
namespace = component.get_config("namespace")
|
|
114
102
|
agent_name = component.get_config("agent_name")
|
|
115
103
|
agent_request_topic = get_agent_request_topic(namespace, agent_name)
|
|
@@ -1240,6 +1228,8 @@ async def handle_a2a_response(component, message: SolaceMessage):
|
|
|
1240
1228
|
component.log_identifier,
|
|
1241
1229
|
sub_task_id,
|
|
1242
1230
|
)
|
|
1231
|
+
# Reset the timeout since we received a status update
|
|
1232
|
+
await component.reset_peer_timeout(sub_task_id)
|
|
1243
1233
|
message.call_acknowledgements()
|
|
1244
1234
|
return
|
|
1245
1235
|
|
|
@@ -17,7 +17,7 @@ This is an empty package initialization file and has no public interfaces.
|
|
|
17
17
|
|
|
18
18
|
### event_handlers.py
|
|
19
19
|
**Purpose:** Central hub for processing all events related to the A2A protocol. Routes events to appropriate handlers and manages task lifecycle.
|
|
20
|
-
**Import:** `from solace_agent_mesh.agent.protocol.event_handlers import process_event, handle_a2a_request, handle_agent_card_message, handle_a2a_response, publish_agent_card`
|
|
20
|
+
**Import:** `from solace_agent_mesh.agent.protocol.event_handlers import process_event, handle_a2a_request, handle_agent_card_message, handle_a2a_response, publish_agent_card, handle_sam_event, cleanup_agent_session`
|
|
21
21
|
|
|
22
22
|
**Functions:**
|
|
23
23
|
- `process_event(component, event: Event) -> None` - Main event router that processes incoming events and delegates to specific handlers based on event type and topic
|
|
@@ -25,6 +25,8 @@ This is an empty package initialization file and has no public interfaces.
|
|
|
25
25
|
- `handle_agent_card_message(component, message: SolaceMessage) -> None` - Processes incoming Agent Card discovery messages and updates peer agent registry
|
|
26
26
|
- `handle_a2a_response(component, message: SolaceMessage) -> None` - Handles responses and status updates from peer agents, manages parallel task completion
|
|
27
27
|
- `publish_agent_card(component) -> None` - Publishes the agent's capabilities and information to the discovery topic
|
|
28
|
+
- `handle_sam_event(component, message: SolaceMessage, topic: str) -> None` - Handles incoming SAM system events like session deletion
|
|
29
|
+
- `cleanup_agent_session(component, session_id: str, user_id: str) -> None` - Cleans up agent-side session data when sessions are deleted
|
|
28
30
|
|
|
29
31
|
**Internal Helper Functions:**
|
|
30
32
|
- `_register_peer_artifacts_in_parent_context(parent_task_context: "TaskExecutionContext", peer_task_object: Task, log_identifier: str) -> None` - Registers artifacts produced by peer agents in the parent task context
|
|
@@ -48,6 +50,16 @@ publish_agent_card(component)
|
|
|
48
50
|
from solace_agent_mesh.agent.protocol.event_handlers import handle_a2a_request
|
|
49
51
|
|
|
50
52
|
await handle_a2a_request(component, solace_message)
|
|
53
|
+
|
|
54
|
+
# Handle SAM system events
|
|
55
|
+
from solace_agent_mesh.agent.protocol.event_handlers import handle_sam_event
|
|
56
|
+
|
|
57
|
+
handle_sam_event(component, message, topic)
|
|
58
|
+
|
|
59
|
+
# Clean up session data
|
|
60
|
+
from solace_agent_mesh.agent.protocol.event_handlers import cleanup_agent_session
|
|
61
|
+
|
|
62
|
+
await cleanup_agent_session(component, "session_123", "user_456")
|
|
51
63
|
```
|
|
52
64
|
|
|
53
65
|
**Key Event Flow:**
|
|
@@ -56,6 +68,7 @@ await handle_a2a_request(component, solace_message)
|
|
|
56
68
|
- Agent request topics → `handle_a2a_request()`
|
|
57
69
|
- Discovery topics → `handle_agent_card_message()`
|
|
58
70
|
- Response/status topics → `handle_a2a_response()`
|
|
71
|
+
- SAM events topics → `handle_sam_event()`
|
|
59
72
|
3. For TIMER events, handles periodic agent card publishing
|
|
60
73
|
4. For CACHE_EXPIRY events, delegates to component's cache handling
|
|
61
74
|
|
|
@@ -65,4 +78,4 @@ await handle_a2a_request(component, solace_message)
|
|
|
65
78
|
- Integrates with Google ADK for task execution
|
|
66
79
|
- Manages task contexts through `TaskExecutionContext`
|
|
67
80
|
|
|
68
|
-
# content_hash:
|
|
81
|
+
# content_hash: 4b8a426320c6f06c621b469c79087c315f5590ef14497ccf17de02eeb66db91d
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# LLM Summary Detail File
|
|
2
|
+
|
|
3
|
+
This file is a concatenation of all individual *llm.txt files found in the 'protocol' directory tree. Each section below corresponds to a specific directory's summary file.
|
|
4
|
+
|
|
5
|
+
================================================================================
|
|
6
|
+
|
|
7
|
+
## Section 1: solace_agent_mesh/agent/protocol/protocol_llm.txt
|
|
8
|
+
|
|
9
|
+
**Source file:** `solace_agent_mesh/agent/protocol/protocol_llm.txt`
|
|
10
|
+
|
|
11
|
+
# DEVELOPER GUIDE: protocol
|
|
12
|
+
|
|
13
|
+
## Quick Summary
|
|
14
|
+
The `protocol` directory implements the core logic for Agent-to-Agent (A2A) communication. It handles receiving and processing requests, responses, and discovery messages (Agent Cards) over the Solace event mesh. It acts as the bridge between the A2A protocol and the underlying Google ADK execution environment.
|
|
15
|
+
|
|
16
|
+
## Files Overview
|
|
17
|
+
- `__init__.py` - Empty package initialization file
|
|
18
|
+
- `event_handlers.py` - Contains the primary logic for handling all A2A protocol events, including routing incoming messages, managing task execution, and handling agent discovery
|
|
19
|
+
|
|
20
|
+
## Developer API Reference
|
|
21
|
+
|
|
22
|
+
### __init__.py
|
|
23
|
+
**Purpose:** Standard Python package initialization file
|
|
24
|
+
**Import:** `from solace_agent_mesh.agent.protocol import *`
|
|
25
|
+
|
|
26
|
+
This is an empty package initialization file and has no public interfaces.
|
|
27
|
+
|
|
28
|
+
### event_handlers.py
|
|
29
|
+
**Purpose:** Central hub for processing all events related to the A2A protocol. Routes events to appropriate handlers and manages task lifecycle.
|
|
30
|
+
**Import:** `from solace_agent_mesh.agent.protocol.event_handlers import process_event, handle_a2a_request, handle_agent_card_message, handle_a2a_response, publish_agent_card, handle_sam_event, cleanup_agent_session`
|
|
31
|
+
|
|
32
|
+
**Functions:**
|
|
33
|
+
- `process_event(component, event: Event) -> None` - Main event router that processes incoming events and delegates to specific handlers based on event type and topic
|
|
34
|
+
- `handle_a2a_request(component, message: SolaceMessage) -> None` - Handles incoming A2A request messages, starts ADK runner for SendTask requests, and processes CancelTask requests
|
|
35
|
+
- `handle_agent_card_message(component, message: SolaceMessage) -> None` - Processes incoming Agent Card discovery messages and updates peer agent registry
|
|
36
|
+
- `handle_a2a_response(component, message: SolaceMessage) -> None` - Handles responses and status updates from peer agents, manages parallel task completion
|
|
37
|
+
- `publish_agent_card(component) -> None` - Publishes the agent's capabilities and information to the discovery topic
|
|
38
|
+
- `handle_sam_event(component, message: SolaceMessage, topic: str) -> None` - Handles incoming SAM system events like session deletion
|
|
39
|
+
- `cleanup_agent_session(component, session_id: str, user_id: str) -> None` - Cleans up agent-side session data when sessions are deleted
|
|
40
|
+
|
|
41
|
+
**Internal Helper Functions:**
|
|
42
|
+
- `_register_peer_artifacts_in_parent_context(parent_task_context: "TaskExecutionContext", peer_task_object: Task, log_identifier: str) -> None` - Registers artifacts produced by peer agents in the parent task context
|
|
43
|
+
- `_publish_peer_tool_result_notification(component: "SamAgentComponent", correlation_data: Dict[str, Any], payload_to_queue: Any, log_identifier: str) -> None` - Publishes a ToolResultData status update for a completed peer tool call
|
|
44
|
+
|
|
45
|
+
**Usage Examples:**
|
|
46
|
+
```python
|
|
47
|
+
# Main event processing (typically called by the SAC framework)
|
|
48
|
+
from solace_agent_mesh.agent.protocol.event_handlers import process_event
|
|
49
|
+
from solace_ai_connector.common.event import Event, EventType
|
|
50
|
+
|
|
51
|
+
# Process an incoming event
|
|
52
|
+
await process_event(component, event)
|
|
53
|
+
|
|
54
|
+
# Publish agent discovery card
|
|
55
|
+
from solace_agent_mesh.agent.protocol.event_handlers import publish_agent_card
|
|
56
|
+
|
|
57
|
+
publish_agent_card(component)
|
|
58
|
+
|
|
59
|
+
# Handle specific message types (usually called internally by process_event)
|
|
60
|
+
from solace_agent_mesh.agent.protocol.event_handlers import handle_a2a_request
|
|
61
|
+
|
|
62
|
+
await handle_a2a_request(component, solace_message)
|
|
63
|
+
|
|
64
|
+
# Handle SAM system events
|
|
65
|
+
from solace_agent_mesh.agent.protocol.event_handlers import handle_sam_event
|
|
66
|
+
|
|
67
|
+
handle_sam_event(component, message, topic)
|
|
68
|
+
|
|
69
|
+
# Clean up session data
|
|
70
|
+
from solace_agent_mesh.agent.protocol.event_handlers import cleanup_agent_session
|
|
71
|
+
|
|
72
|
+
await cleanup_agent_session(component, "session_123", "user_456")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Key Event Flow:**
|
|
76
|
+
1. `process_event()` receives all events and routes based on type (MESSAGE, TIMER, CACHE_EXPIRY)
|
|
77
|
+
2. For MESSAGE events, routes to specific handlers based on topic patterns:
|
|
78
|
+
- Agent request topics → `handle_a2a_request()`
|
|
79
|
+
- Discovery topics → `handle_agent_card_message()`
|
|
80
|
+
- Response/status topics → `handle_a2a_response()`
|
|
81
|
+
- SAM events topics → `handle_sam_event()`
|
|
82
|
+
3. For TIMER events, handles periodic agent card publishing
|
|
83
|
+
4. For CACHE_EXPIRY events, delegates to component's cache handling
|
|
84
|
+
|
|
85
|
+
**Dependencies:**
|
|
86
|
+
- Requires `SamAgentComponent` instance with proper configuration
|
|
87
|
+
- Uses A2A protocol types from `a2a.types`
|
|
88
|
+
- Integrates with Google ADK for task execution
|
|
89
|
+
- Manages task contexts through `TaskExecutionContext`
|
|
90
|
+
|
|
91
|
+
================================================================================
|
|
92
|
+
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import sys
|
|
2
3
|
import os
|
|
3
4
|
|
|
@@ -7,7 +8,6 @@ sys.path.insert(
|
|
|
7
8
|
|
|
8
9
|
from common.utils.asyncio_macos_fix import ensure_asyncio_compatibility
|
|
9
10
|
from .patch_adk import patch_adk
|
|
10
|
-
from solace_ai_connector.common.log import log
|
|
11
11
|
|
|
12
12
|
ensure_asyncio_compatibility()
|
|
13
13
|
patch_adk()
|
|
@@ -29,6 +29,8 @@ from ...agent.utils.artifact_helpers import DEFAULT_SCHEMA_MAX_KEYS
|
|
|
29
29
|
from ...common.utils.pydantic_utils import SamConfigBase
|
|
30
30
|
from ..tools.tool_config_types import AnyToolConfig
|
|
31
31
|
|
|
32
|
+
log = logging.getLogger(__name__)
|
|
33
|
+
|
|
32
34
|
info = {
|
|
33
35
|
"class_name": "SamAgentApp",
|
|
34
36
|
"description": "Custom App class for SAM Agent Host with namespace prefixing and automatic subscription generation.",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Custom Solace AI Connector Component to Host Google ADK Agents via A2A Protocol.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import logging
|
|
5
6
|
from typing import Any, Dict, Optional, Union, Callable, List, Tuple, TYPE_CHECKING
|
|
6
7
|
import asyncio
|
|
7
8
|
import functools
|
|
@@ -15,8 +16,8 @@ import json
|
|
|
15
16
|
from solace_ai_connector.common.message import (
|
|
16
17
|
Message as SolaceMessage,
|
|
17
18
|
)
|
|
18
|
-
from solace_ai_connector.common.log import log
|
|
19
19
|
from solace_ai_connector.common.event import Event, EventType
|
|
20
|
+
|
|
20
21
|
from solace_ai_connector.common.utils import import_module
|
|
21
22
|
import inspect
|
|
22
23
|
from pydantic import BaseModel, ValidationError
|
|
@@ -71,12 +72,13 @@ from ...agent.tools.peer_agent_tool import (
|
|
|
71
72
|
PeerAgentTool,
|
|
72
73
|
PEER_TOOL_PREFIX,
|
|
73
74
|
)
|
|
74
|
-
from ...agent.adk.invocation_monitor import InvocationMonitor
|
|
75
75
|
from ...common.middleware.registry import MiddlewareRegistry
|
|
76
76
|
from ...common.constants import DEFAULT_COMMUNICATION_TIMEOUT
|
|
77
77
|
from ...agent.tools.registry import tool_registry
|
|
78
78
|
from ...common.sac.sam_component_base import SamComponentBase
|
|
79
79
|
|
|
80
|
+
log = logging.getLogger(__name__)
|
|
81
|
+
|
|
80
82
|
if TYPE_CHECKING:
|
|
81
83
|
from .app import AgentInitCleanupConfig
|
|
82
84
|
from .task_execution_context import TaskExecutionContext
|
|
@@ -248,7 +250,6 @@ class SamAgentComponent(SamComponentBase):
|
|
|
248
250
|
self._agent_system_instruction_callback: Optional[
|
|
249
251
|
Callable[[CallbackContext, LlmRequest], Optional[str]]
|
|
250
252
|
] = None
|
|
251
|
-
self.invocation_monitor: Optional[InvocationMonitor] = None
|
|
252
253
|
self._active_background_tasks = set()
|
|
253
254
|
try:
|
|
254
255
|
self.agent_specific_state: Dict[str, Any] = {}
|
|
@@ -389,15 +390,6 @@ class SamAgentComponent(SamComponentBase):
|
|
|
389
390
|
raise RuntimeError(
|
|
390
391
|
f"Agent custom initialization failed: {e}"
|
|
391
392
|
) from e
|
|
392
|
-
try:
|
|
393
|
-
self.invocation_monitor = InvocationMonitor()
|
|
394
|
-
except Exception as im_e:
|
|
395
|
-
log.error(
|
|
396
|
-
"%s Failed to initialize InvocationMonitor: %s",
|
|
397
|
-
self.log_identifier,
|
|
398
|
-
im_e,
|
|
399
|
-
)
|
|
400
|
-
self.invocation_monitor = None
|
|
401
393
|
|
|
402
394
|
# Async init is now handled by the base class `run` method.
|
|
403
395
|
# We still need a future to signal completion from the async thread.
|
|
@@ -619,6 +611,42 @@ class SamAgentComponent(SamComponentBase):
|
|
|
619
611
|
log.warning("%s Failed to claim; it was already completed.", log_id)
|
|
620
612
|
return None
|
|
621
613
|
|
|
614
|
+
async def reset_peer_timeout(self, sub_task_id: str):
|
|
615
|
+
"""
|
|
616
|
+
Resets the timeout for a given peer sub-task.
|
|
617
|
+
"""
|
|
618
|
+
log_id = f"{self.log_identifier}[ResetTimeout:{sub_task_id}]"
|
|
619
|
+
log.debug("%s Resetting timeout for peer sub-task.", log_id)
|
|
620
|
+
|
|
621
|
+
# Get the original logical task ID from the cache without removing it
|
|
622
|
+
logical_task_id = self.cache_service.get_data(sub_task_id)
|
|
623
|
+
if not logical_task_id:
|
|
624
|
+
log.warning(
|
|
625
|
+
"%s No active task found for sub-task %s. Cannot reset timeout.",
|
|
626
|
+
log_id,
|
|
627
|
+
sub_task_id,
|
|
628
|
+
)
|
|
629
|
+
return
|
|
630
|
+
|
|
631
|
+
# Get the configured timeout
|
|
632
|
+
timeout_sec = self.inter_agent_communication_config.get(
|
|
633
|
+
"request_timeout_seconds", DEFAULT_COMMUNICATION_TIMEOUT
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
# Update the cache with a new expiry
|
|
637
|
+
self.cache_service.add_data(
|
|
638
|
+
key=sub_task_id,
|
|
639
|
+
value=logical_task_id,
|
|
640
|
+
expiry=timeout_sec,
|
|
641
|
+
component=self,
|
|
642
|
+
)
|
|
643
|
+
log.info(
|
|
644
|
+
"%s Timeout for sub-task %s has been reset to %d seconds.",
|
|
645
|
+
log_id,
|
|
646
|
+
sub_task_id,
|
|
647
|
+
timeout_sec,
|
|
648
|
+
)
|
|
649
|
+
|
|
622
650
|
async def _retrigger_agent_with_peer_responses(
|
|
623
651
|
self,
|
|
624
652
|
results_to_inject: list,
|
|
@@ -2050,6 +2078,21 @@ class SamAgentComponent(SamComponentBase):
|
|
|
2050
2078
|
self.log_identifier,
|
|
2051
2079
|
len(task_context.produced_artifacts),
|
|
2052
2080
|
)
|
|
2081
|
+
|
|
2082
|
+
# Add token usage summary
|
|
2083
|
+
if task_context:
|
|
2084
|
+
token_summary = task_context.get_token_usage_summary()
|
|
2085
|
+
if token_summary["total_tokens"] > 0:
|
|
2086
|
+
final_task_metadata["token_usage"] = token_summary
|
|
2087
|
+
log.info(
|
|
2088
|
+
"%s Task %s used %d total tokens (input: %d, output: %d, cached: %d)",
|
|
2089
|
+
self.log_identifier,
|
|
2090
|
+
logical_task_id,
|
|
2091
|
+
token_summary["total_tokens"],
|
|
2092
|
+
token_summary["total_input_tokens"],
|
|
2093
|
+
token_summary["total_output_tokens"],
|
|
2094
|
+
token_summary["total_cached_input_tokens"],
|
|
2095
|
+
)
|
|
2053
2096
|
|
|
2054
2097
|
final_task = a2a.create_final_task(
|
|
2055
2098
|
task_id=logical_task_id,
|
|
@@ -2991,16 +3034,6 @@ class SamAgentComponent(SamComponentBase):
|
|
|
2991
3034
|
func_name,
|
|
2992
3035
|
e,
|
|
2993
3036
|
)
|
|
2994
|
-
if self.invocation_monitor:
|
|
2995
|
-
try:
|
|
2996
|
-
self.invocation_monitor.cleanup()
|
|
2997
|
-
except Exception as im_clean_e:
|
|
2998
|
-
log.error(
|
|
2999
|
-
"%s Error during InvocationMonitor cleanup: %s",
|
|
3000
|
-
self.log_identifier,
|
|
3001
|
-
im_clean_e,
|
|
3002
|
-
)
|
|
3003
|
-
|
|
3004
3037
|
if self._tool_cleanup_hooks:
|
|
3005
3038
|
log.info(
|
|
3006
3039
|
"%s Executing %d tool cleanup hooks...",
|
|
@@ -141,6 +141,8 @@ patch_adk()
|
|
|
141
141
|
- `get_and_clear_artifact_signals() -> List[Dict[str, Any]]` - Retrieves and clears artifact signals
|
|
142
142
|
- `set_event_loop(loop: asyncio.AbstractEventLoop) -> None` - Stores event loop reference
|
|
143
143
|
- `get_event_loop() -> Optional[asyncio.AbstractEventLoop]` - Retrieves stored event loop
|
|
144
|
+
- `record_token_usage(input_tokens: int, output_tokens: int, model: str, source: str = "agent", tool_name: Optional[str] = None, cached_input_tokens: int = 0) -> None` - Records token usage for LLM calls
|
|
145
|
+
- `get_token_usage_summary() -> Dict[str, Any]` - Returns summary of all token usage for the task
|
|
144
146
|
|
|
145
147
|
**Usage Examples:**
|
|
146
148
|
```python
|
|
@@ -170,6 +172,18 @@ task_context.register_peer_sub_task("sub-task-456", correlation_data)
|
|
|
170
172
|
completed_data = task_context.claim_sub_task_completion("sub-task-456")
|
|
171
173
|
if completed_data:
|
|
172
174
|
print(f"Sub-task completed: {completed_data}")
|
|
175
|
+
|
|
176
|
+
# Track token usage
|
|
177
|
+
task_context.record_token_usage(
|
|
178
|
+
input_tokens=100,
|
|
179
|
+
output_tokens=50,
|
|
180
|
+
model="gemini-1.5-pro",
|
|
181
|
+
source="agent"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Get usage summary
|
|
185
|
+
usage = task_context.get_token_usage_summary()
|
|
186
|
+
print(f"Total tokens used: {usage['total_tokens']}")
|
|
173
187
|
```
|
|
174
188
|
|
|
175
|
-
# content_hash:
|
|
189
|
+
# content_hash: 27b0000d250131d578d28ab8c4d06c2e2084d888b47102e9b3b133adbc61a169
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# LLM Summary Detail File
|
|
2
|
+
|
|
3
|
+
This file is a concatenation of all individual *llm.txt files found in the 'sac' directory tree. Each section below corresponds to a specific directory's summary file.
|
|
4
|
+
|
|
5
|
+
================================================================================
|
|
6
|
+
|
|
7
|
+
## Section 1: solace_agent_mesh/agent/sac/sac_llm.txt
|
|
8
|
+
|
|
9
|
+
**Source file:** `solace_agent_mesh/agent/sac/sac_llm.txt`
|
|
10
|
+
|
|
11
|
+
# DEVELOPER GUIDE for the directory: sac
|
|
12
|
+
|
|
13
|
+
## Quick Summary
|
|
14
|
+
The `sac` (Solace AI Connector) directory provides the core implementation for hosting a Google ADK (Agent Development Kit) agent within the Solace AI Connector framework. It acts as a bridge, enabling ADK agents to communicate using the A2A (Agent-to-Agent) protocol over Solace messaging. This allows for the creation of distributed, collaborative agent systems where agents can delegate tasks, share information, and work together to solve complex problems.
|
|
15
|
+
|
|
16
|
+
## Files Overview
|
|
17
|
+
- `__init__.py` - Empty package marker file
|
|
18
|
+
- `app.py` - Custom SAC App class that automatically configures Solace subscriptions and broker settings for A2A communication
|
|
19
|
+
- `component.py` - Main SAC Component that hosts the ADK agent, manages its lifecycle, and handles all A2A protocol messaging
|
|
20
|
+
- `patch_adk.py` - Runtime patches for the Google ADK library to enhance or correct its behavior
|
|
21
|
+
- `task_execution_context.py` - State management class that encapsulates all runtime information for a single, in-flight A2A task
|
|
22
|
+
|
|
23
|
+
## Developer API Reference
|
|
24
|
+
|
|
25
|
+
### app.py
|
|
26
|
+
**Purpose:** Provides a custom SAC App class that simplifies the configuration of an A2A agent
|
|
27
|
+
**Import:** `from solace_agent_mesh.agent.sac.app import SamAgentApp`
|
|
28
|
+
|
|
29
|
+
**Classes:**
|
|
30
|
+
- `SamAgentApp(app_info: Dict[str, Any], **kwargs)` - Custom App class for SAM Agent Host with namespace prefixing and automatic subscription generation
|
|
31
|
+
- `app_schema: Dict` - Class attribute defining comprehensive configuration schema for agent host validation
|
|
32
|
+
|
|
33
|
+
**Constants/Variables:**
|
|
34
|
+
- `info: Dict[str, str]` - Metadata dictionary about the SamAgentApp class for SAC framework discovery
|
|
35
|
+
|
|
36
|
+
**Usage Examples:**
|
|
37
|
+
```python
|
|
38
|
+
# SamAgentApp is typically instantiated by the SAC framework from YAML config
|
|
39
|
+
# Example agent-config.yaml:
|
|
40
|
+
# app:
|
|
41
|
+
# class_name: solace_agent_mesh.agent.sac.app.SamAgentApp
|
|
42
|
+
# app_config:
|
|
43
|
+
# namespace: "my-org/production"
|
|
44
|
+
# agent_name: "customer-support-agent"
|
|
45
|
+
# model: "gemini-1.5-pro-latest"
|
|
46
|
+
# tools:
|
|
47
|
+
# - tool_type: "builtin"
|
|
48
|
+
# tool_name: "file_search"
|
|
49
|
+
# agent_card:
|
|
50
|
+
# description: "An agent that can answer questions about customer accounts."
|
|
51
|
+
# agent_card_publishing:
|
|
52
|
+
# interval_seconds: 60
|
|
53
|
+
# session_service:
|
|
54
|
+
# type: "memory"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### component.py
|
|
58
|
+
**Purpose:** Core component that hosts a Google ADK agent and bridges communication to A2A protocol
|
|
59
|
+
**Import:** `from solace_agent_mesh.agent.sac.component import SamAgentComponent`
|
|
60
|
+
|
|
61
|
+
**Classes:**
|
|
62
|
+
- `SamAgentComponent(**kwargs)` - Solace AI Connector component that hosts a Google ADK agent
|
|
63
|
+
- `process_event(event: Event) -> None` - Main entry point for all SAC framework events
|
|
64
|
+
- `handle_timer_event(timer_data: Dict[str, Any]) -> None` - Handles scheduled timer events for agent card publishing
|
|
65
|
+
- `handle_cache_expiry_event(cache_data: Dict[str, Any]) -> None` - Handles cache expiry events for peer agent timeouts
|
|
66
|
+
- `finalize_task_success(a2a_context: Dict) -> None` - Async method to finalize successful task completion
|
|
67
|
+
- `finalize_task_canceled(a2a_context: Dict) -> None` - Finalizes task as CANCELED
|
|
68
|
+
- `finalize_task_error(exception: Exception, a2a_context: Dict) -> None` - Async method to finalize failed tasks
|
|
69
|
+
- `cleanup() -> None` - Cleans up resources on component shutdown
|
|
70
|
+
- `set_agent_specific_state(key: str, value: Any) -> None` - Sets key-value pair in agent state dictionary
|
|
71
|
+
- `get_agent_specific_state(key: str, default: Optional[Any] = None) -> Any` - Retrieves value from agent state
|
|
72
|
+
- `get_async_loop() -> Optional[asyncio.AbstractEventLoop]` - Returns dedicated asyncio event loop
|
|
73
|
+
- `set_agent_system_instruction_string(instruction_string: str) -> None` - Sets static system prompt injection
|
|
74
|
+
- `set_agent_system_instruction_callback(callback_function: Callable) -> None` - Sets dynamic system prompt callback
|
|
75
|
+
- `get_gateway_id() -> str` - Returns unique identifier for agent host instance
|
|
76
|
+
- `submit_a2a_task(target_agent_name: str, a2a_message: A2AMessage, user_id: str, user_config: Dict[str, Any], sub_task_id: str) -> str` - Submits task to peer agent
|
|
77
|
+
- `get_agent_context() -> Dict[str, Any]` - Returns agent context for middleware interactions
|
|
78
|
+
|
|
79
|
+
**Constants/Variables:**
|
|
80
|
+
- `info: Dict` - Metadata dictionary for SAC framework
|
|
81
|
+
- `CORRELATION_DATA_PREFIX: str` - Prefix for cache keys when tracking peer requests
|
|
82
|
+
- `HOST_COMPONENT_VERSION: str` - Version string of the host component
|
|
83
|
+
|
|
84
|
+
**Usage Examples:**
|
|
85
|
+
```python
|
|
86
|
+
# Custom initialization function example
|
|
87
|
+
from solace_agent_mesh.agent.sac.component import SamAgentComponent
|
|
88
|
+
|
|
89
|
+
def initialize_my_agent(host_component: SamAgentComponent, config: dict):
|
|
90
|
+
"""Custom initialization function for the agent."""
|
|
91
|
+
# Store database connection in agent state
|
|
92
|
+
db_connection = create_database_connection(config.get('db_url'))
|
|
93
|
+
host_component.set_agent_specific_state('db_connection', db_connection)
|
|
94
|
+
|
|
95
|
+
# Set custom system instruction
|
|
96
|
+
host_component.set_agent_system_instruction_string(
|
|
97
|
+
"You are a specialized customer service agent with access to our database."
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Tool accessing agent state
|
|
101
|
+
def my_custom_tool(host_component: SamAgentComponent, query: str) -> str:
|
|
102
|
+
"""Tool that uses stored database connection."""
|
|
103
|
+
db_connection = host_component.get_agent_specific_state('db_connection')
|
|
104
|
+
if db_connection:
|
|
105
|
+
return db_connection.execute_query(query)
|
|
106
|
+
return "Database not available"
|
|
107
|
+
|
|
108
|
+
# Scheduling async work from synchronous code
|
|
109
|
+
def schedule_background_task(host_component: SamAgentComponent):
|
|
110
|
+
"""Schedule async work on the component's event loop."""
|
|
111
|
+
loop = host_component.get_async_loop()
|
|
112
|
+
if loop:
|
|
113
|
+
asyncio.run_coroutine_threadsafe(my_async_task(), loop)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### patch_adk.py
|
|
117
|
+
**Purpose:** Contains runtime patches for the Google ADK library to enhance behavior
|
|
118
|
+
**Import:** `from solace_agent_mesh.agent.sac.patch_adk import patch_adk`
|
|
119
|
+
|
|
120
|
+
**Functions:**
|
|
121
|
+
- `patch_adk() -> None` - Applies all necessary patches to the ADK library
|
|
122
|
+
|
|
123
|
+
**Usage Examples:**
|
|
124
|
+
```python
|
|
125
|
+
from solace_agent_mesh.agent.sac.patch_adk import patch_adk
|
|
126
|
+
|
|
127
|
+
# Apply patches before using ADK
|
|
128
|
+
patch_adk()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### task_execution_context.py
|
|
132
|
+
**Purpose:** State management class for single, in-flight agent tasks
|
|
133
|
+
**Import:** `from solace_agent_mesh.agent.sac.task_execution_context import TaskExecutionContext`
|
|
134
|
+
|
|
135
|
+
**Classes:**
|
|
136
|
+
- `TaskExecutionContext(task_id: str, a2a_context: Dict[str, Any])` - Encapsulates runtime state for a single agent task
|
|
137
|
+
- `cancel() -> None` - Signals that the task should be cancelled
|
|
138
|
+
- `is_cancelled() -> bool` - Checks if cancellation event has been set
|
|
139
|
+
- `append_to_streaming_buffer(text: str) -> None` - Appends text to streaming buffer
|
|
140
|
+
- `flush_streaming_buffer() -> str` - Returns and clears streaming buffer content
|
|
141
|
+
- `get_streaming_buffer_content() -> str` - Returns buffer content without clearing
|
|
142
|
+
- `append_to_run_based_buffer(text: str) -> None` - Appends text to run-based response buffer
|
|
143
|
+
- `register_peer_sub_task(sub_task_id: str, correlation_data: Dict[str, Any]) -> None` - Adds peer sub-task tracking
|
|
144
|
+
- `claim_sub_task_completion(sub_task_id: str) -> Optional[Dict[str, Any]]` - Atomically retrieves and removes sub-task data
|
|
145
|
+
- `register_parallel_call_sent(invocation_id: str) -> None` - Registers new parallel tool call
|
|
146
|
+
- `handle_peer_timeout(sub_task_id: str, correlation_data: Dict, timeout_sec: int, invocation_id: str) -> bool` - Handles peer timeout
|
|
147
|
+
- `record_parallel_result(result: Dict, invocation_id: str) -> bool` - Records parallel tool call result
|
|
148
|
+
- `clear_parallel_invocation_state(invocation_id: str) -> None` - Removes completed invocation state
|
|
149
|
+
- `register_produced_artifact(filename: str, version: int) -> None` - Tracks newly created artifacts
|
|
150
|
+
- `add_artifact_signal(signal: Dict[str, Any]) -> None` - Adds artifact return signal
|
|
151
|
+
- `get_and_clear_artifact_signals() -> List[Dict[str, Any]]` - Retrieves and clears artifact signals
|
|
152
|
+
- `set_event_loop(loop: asyncio.AbstractEventLoop) -> None` - Stores event loop reference
|
|
153
|
+
- `get_event_loop() -> Optional[asyncio.AbstractEventLoop]` - Retrieves stored event loop
|
|
154
|
+
- `record_token_usage(input_tokens: int, output_tokens: int, model: str, source: str = "agent", tool_name: Optional[str] = None, cached_input_tokens: int = 0) -> None` - Records token usage for LLM calls
|
|
155
|
+
- `get_token_usage_summary() -> Dict[str, Any]` - Returns summary of all token usage for the task
|
|
156
|
+
|
|
157
|
+
**Usage Examples:**
|
|
158
|
+
```python
|
|
159
|
+
from solace_agent_mesh.agent.sac.task_execution_context import TaskExecutionContext
|
|
160
|
+
|
|
161
|
+
# Create task context
|
|
162
|
+
a2a_context = {
|
|
163
|
+
"logical_task_id": "task-123",
|
|
164
|
+
"user_id": "user-456",
|
|
165
|
+
"session_id": "session-789"
|
|
166
|
+
}
|
|
167
|
+
task_context = TaskExecutionContext("task-123", a2a_context)
|
|
168
|
+
|
|
169
|
+
# Use streaming buffer
|
|
170
|
+
task_context.append_to_streaming_buffer("Hello ")
|
|
171
|
+
task_context.append_to_streaming_buffer("world!")
|
|
172
|
+
content = task_context.flush_streaming_buffer() # Returns "Hello world!"
|
|
173
|
+
|
|
174
|
+
# Track peer sub-tasks
|
|
175
|
+
correlation_data = {
|
|
176
|
+
"peer_agent_name": "math-agent",
|
|
177
|
+
"adk_function_call_id": "call-123"
|
|
178
|
+
}
|
|
179
|
+
task_context.register_peer_sub_task("sub-task-456", correlation_data)
|
|
180
|
+
|
|
181
|
+
# Handle completion
|
|
182
|
+
completed_data = task_context.claim_sub_task_completion("sub-task-456")
|
|
183
|
+
if completed_data:
|
|
184
|
+
print(f"Sub-task completed: {completed_data}")
|
|
185
|
+
|
|
186
|
+
# Track token usage
|
|
187
|
+
task_context.record_token_usage(
|
|
188
|
+
input_tokens=100,
|
|
189
|
+
output_tokens=50,
|
|
190
|
+
model="gemini-1.5-pro",
|
|
191
|
+
source="agent"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Get usage summary
|
|
195
|
+
usage = task_context.get_token_usage_summary()
|
|
196
|
+
print(f"Total tokens used: {usage['total_tokens']}")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
================================================================================
|
|
200
|
+
|
|
@@ -33,6 +33,13 @@ class TaskExecutionContext:
|
|
|
33
33
|
self.artifact_signals_to_return: List[Dict[str, Any]] = []
|
|
34
34
|
self.event_loop: Optional[asyncio.AbstractEventLoop] = None
|
|
35
35
|
self.lock: threading.Lock = threading.Lock()
|
|
36
|
+
|
|
37
|
+
# Token usage tracking
|
|
38
|
+
self.total_input_tokens: int = 0
|
|
39
|
+
self.total_output_tokens: int = 0
|
|
40
|
+
self.total_cached_input_tokens: int = 0
|
|
41
|
+
self.token_usage_by_model: Dict[str, Dict[str, int]] = {}
|
|
42
|
+
self.token_usage_by_source: Dict[str, Dict[str, int]] = {}
|
|
36
43
|
|
|
37
44
|
def cancel(self) -> None:
|
|
38
45
|
"""Signals that the task should be cancelled."""
|
|
@@ -183,3 +190,69 @@ class TaskExecutionContext:
|
|
|
183
190
|
"""Retrieves the stored event loop."""
|
|
184
191
|
with self.lock:
|
|
185
192
|
return self.event_loop
|
|
193
|
+
|
|
194
|
+
def record_token_usage(
|
|
195
|
+
self,
|
|
196
|
+
input_tokens: int,
|
|
197
|
+
output_tokens: int,
|
|
198
|
+
model: str,
|
|
199
|
+
source: str = "agent",
|
|
200
|
+
tool_name: Optional[str] = None,
|
|
201
|
+
cached_input_tokens: int = 0,
|
|
202
|
+
) -> None:
|
|
203
|
+
"""
|
|
204
|
+
Records token usage for an LLM call.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
input_tokens: Number of input/prompt tokens.
|
|
208
|
+
output_tokens: Number of output/completion tokens.
|
|
209
|
+
model: Model identifier used for this call.
|
|
210
|
+
source: Source of the LLM call ("agent" or "tool").
|
|
211
|
+
tool_name: Tool name if source is "tool".
|
|
212
|
+
cached_input_tokens: Number of cached input tokens (optional).
|
|
213
|
+
"""
|
|
214
|
+
with self.lock:
|
|
215
|
+
# Update totals
|
|
216
|
+
self.total_input_tokens += input_tokens
|
|
217
|
+
self.total_output_tokens += output_tokens
|
|
218
|
+
self.total_cached_input_tokens += cached_input_tokens
|
|
219
|
+
|
|
220
|
+
# Track by model
|
|
221
|
+
if model not in self.token_usage_by_model:
|
|
222
|
+
self.token_usage_by_model[model] = {
|
|
223
|
+
"input_tokens": 0,
|
|
224
|
+
"output_tokens": 0,
|
|
225
|
+
"cached_input_tokens": 0,
|
|
226
|
+
}
|
|
227
|
+
self.token_usage_by_model[model]["input_tokens"] += input_tokens
|
|
228
|
+
self.token_usage_by_model[model]["output_tokens"] += output_tokens
|
|
229
|
+
self.token_usage_by_model[model]["cached_input_tokens"] += cached_input_tokens
|
|
230
|
+
|
|
231
|
+
# Track by source
|
|
232
|
+
source_key = f"{source}:{tool_name}" if tool_name else source
|
|
233
|
+
if source_key not in self.token_usage_by_source:
|
|
234
|
+
self.token_usage_by_source[source_key] = {
|
|
235
|
+
"input_tokens": 0,
|
|
236
|
+
"output_tokens": 0,
|
|
237
|
+
"cached_input_tokens": 0,
|
|
238
|
+
}
|
|
239
|
+
self.token_usage_by_source[source_key]["input_tokens"] += input_tokens
|
|
240
|
+
self.token_usage_by_source[source_key]["output_tokens"] += output_tokens
|
|
241
|
+
self.token_usage_by_source[source_key]["cached_input_tokens"] += cached_input_tokens
|
|
242
|
+
|
|
243
|
+
def get_token_usage_summary(self) -> Dict[str, Any]:
|
|
244
|
+
"""
|
|
245
|
+
Returns a summary of all token usage for this task.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
Dictionary containing total token counts and breakdowns by model and source.
|
|
249
|
+
"""
|
|
250
|
+
with self.lock:
|
|
251
|
+
return {
|
|
252
|
+
"total_input_tokens": self.total_input_tokens,
|
|
253
|
+
"total_output_tokens": self.total_output_tokens,
|
|
254
|
+
"total_cached_input_tokens": self.total_cached_input_tokens,
|
|
255
|
+
"total_tokens": self.total_input_tokens + self.total_output_tokens,
|
|
256
|
+
"by_model": dict(self.token_usage_by_model),
|
|
257
|
+
"by_source": dict(self.token_usage_by_source),
|
|
258
|
+
}
|