connectonion 0.6.1__py3-none-any.whl → 0.6.3__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.
- connectonion/__init__.py +46 -9
- connectonion/cli/__init__.py +11 -1
- connectonion/cli/browser_agent/__init__.py +11 -1
- connectonion/cli/browser_agent/browser.py +95 -142
- connectonion/cli/browser_agent/element_finder.py +147 -0
- connectonion/cli/browser_agent/highlight_screenshot.py +182 -0
- connectonion/cli/browser_agent/prompt.md +188 -105
- connectonion/cli/browser_agent/prompts/element_matcher.md +59 -0
- connectonion/cli/browser_agent/prompts/form_filler.md +19 -0
- connectonion/cli/browser_agent/prompts/scroll_strategy.md +36 -0
- connectonion/cli/browser_agent/scripts/extract_elements.js +126 -0
- connectonion/cli/browser_agent/scroll.py +145 -0
- connectonion/cli/co_ai/__init__.py +6 -0
- connectonion/cli/co_ai/agent.py +87 -0
- connectonion/cli/co_ai/agents/__init__.py +5 -0
- connectonion/cli/co_ai/agents/registry.py +57 -0
- connectonion/cli/co_ai/commands/__init__.py +45 -0
- connectonion/cli/co_ai/commands/compact.py +173 -0
- connectonion/cli/co_ai/commands/cost.py +77 -0
- connectonion/cli/co_ai/commands/export.py +60 -0
- connectonion/cli/co_ai/commands/help.py +80 -0
- connectonion/cli/co_ai/commands/init.py +101 -0
- connectonion/cli/co_ai/commands/sessions.py +55 -0
- connectonion/cli/co_ai/commands/tasks.py +63 -0
- connectonion/cli/co_ai/commands/undo.py +103 -0
- connectonion/cli/co_ai/context.py +127 -0
- connectonion/cli/co_ai/main.py +52 -0
- connectonion/cli/co_ai/plugins/__init__.py +6 -0
- connectonion/cli/co_ai/plugins/reminder.py +76 -0
- connectonion/cli/co_ai/plugins/shell_approval.py +105 -0
- connectonion/cli/co_ai/prompts/agents/explore.md +79 -0
- connectonion/cli/co_ai/prompts/agents/plan.md +60 -0
- connectonion/cli/co_ai/prompts/assembler.py +303 -0
- connectonion/cli/{docs/co-vibecoding-principles-docs-contexts-all-in-one.md → co_ai/prompts/connectonion/README.md} +26 -0
- connectonion/cli/co_ai/prompts/connectonion/api.md +457 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/README.md +805 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/auth.md +46 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/browser.md +235 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/copy.md +184 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/create.md +335 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/init.md +431 -0
- connectonion/cli/co_ai/prompts/connectonion/co-directory-structure.md +214 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/agent.md +1078 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/events.md +816 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/llm_do.md +256 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/max_iterations.md +362 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/models.md +641 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/plugins.md +100 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/prompts.md +122 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/tools.md +512 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/transcribe.md +156 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/trust.md +291 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/README.md +18 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/auto_debug.md +1026 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/console.md +129 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/eval-format.md +178 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/eval.md +230 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/exceptions.md +307 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/log.md +117 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/xray.md +215 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/001-choosing-input-method.md +202 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/002-choosing-llm-function-name.md +202 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/003-choosing-trust-keyword.md +141 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/004-cli-create-flow.md +117 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/005-designing-agent-network-protocol.md +503 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/006-agent-address-format.md +305 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/007-authentication-backend-design.md +240 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/008-naming-is-hard.md +228 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/009-why-connect-function.md +167 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/010-cli-ux-progressive-disclosure.md +176 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/011-global-config-identity-management.md +357 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/012-tool-execution-separation.md +259 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/013-debug-and-logging-design.md +253 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/014-hook-system-design.md +510 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/015-interactive-auto-debug-design.md +837 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/016-why-no-zero-knowledge-proofs.md +358 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/017-session-logging-and-eval-format.md +120 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/018-event-api-naming.md +274 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/019-agent-lifecycle-design.md +655 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/020-trust-system-and-network-architecture.md +503 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/021-task-storage-jsonl-design.md +496 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/022-raw-asgi-implementation.md +273 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/agent_reasoning.md +62 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/atomic_tools.md +24 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/load_guide.md +18 -0
- connectonion/cli/co_ai/prompts/connectonion/examples.md +0 -0
- connectonion/cli/co_ai/prompts/connectonion/hook-system-options.md +364 -0
- connectonion/cli/co_ai/prompts/connectonion/index.md +162 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/README.md +12 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/auth.md +450 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/google.md +431 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/microsoft.md +370 -0
- connectonion/cli/co_ai/prompts/connectonion/network/README.md +14 -0
- connectonion/cli/co_ai/prompts/connectonion/network/connect.md +543 -0
- connectonion/cli/co_ai/prompts/connectonion/network/connection.md +538 -0
- connectonion/cli/co_ai/prompts/connectonion/network/deploy.md +123 -0
- connectonion/cli/co_ai/prompts/connectonion/network/host.md +1049 -0
- connectonion/cli/co_ai/prompts/connectonion/network/protocol/agent-relay-protocol.md +495 -0
- connectonion/cli/co_ai/prompts/connectonion/network/protocol/announce-message.md +115 -0
- connectonion/cli/co_ai/prompts/connectonion/principles.md +124 -0
- connectonion/cli/co_ai/prompts/connectonion/quickstart.md +261 -0
- connectonion/cli/co_ai/prompts/connectonion/roadmap.md +81 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/README.md +77 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/meta-agent.md +152 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/minimal.md +105 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/playwright.md +130 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/web-research.md +144 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/README.md +95 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/chat.md +181 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/divider.md +63 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/dropdown.md +83 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/footer.md +44 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/fuzzy.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/input.md +84 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/keys.md +77 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/pick.md +71 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/providers.md +89 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/status_bar.md +67 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/README.md +156 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/calendar_plugin.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/eval.md +89 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/gmail_plugin.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/image_result_formatter.md +74 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/re_act.md +86 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/shell_approval.md +69 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/README.md +81 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/diff_writer.md +138 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/get_emails.md +499 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/gmail.md +135 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/google_calendar.md +106 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/memory.md +486 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/microsoft_calendar.md +106 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/outlook.md +120 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/send_email.md +403 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/shell.md +95 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/slash_command.md +96 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/terminal.md +97 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/todo_list.md +252 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/web_fetch.md +130 -0
- connectonion/cli/co_ai/prompts/connectonion/vibe-coding-guide.md +97 -0
- connectonion/cli/co_ai/prompts/connectonion/windows-support.md +258 -0
- connectonion/cli/co_ai/prompts/main.md +247 -0
- connectonion/cli/co_ai/prompts/reminders/plan_mode.md +34 -0
- connectonion/cli/co_ai/prompts/summarization.md +55 -0
- connectonion/cli/co_ai/prompts/tools/ask_user.md +61 -0
- connectonion/cli/co_ai/prompts/tools/background.md +57 -0
- connectonion/cli/co_ai/prompts/tools/edit.md +90 -0
- connectonion/cli/co_ai/prompts/tools/glob.md +52 -0
- connectonion/cli/co_ai/prompts/tools/grep.md +55 -0
- connectonion/cli/co_ai/prompts/tools/plan_mode.md +80 -0
- connectonion/cli/co_ai/prompts/tools/read.md +40 -0
- connectonion/cli/co_ai/prompts/tools/shell.md +67 -0
- connectonion/cli/co_ai/prompts/tools/task.md +51 -0
- connectonion/cli/co_ai/prompts/tools/todo.md +139 -0
- connectonion/cli/co_ai/prompts/tools/write.md +47 -0
- connectonion/cli/co_ai/prompts/workflow.md +89 -0
- connectonion/cli/co_ai/reminders.py +159 -0
- connectonion/cli/co_ai/sessions.py +110 -0
- connectonion/cli/co_ai/skills/__init__.py +37 -0
- connectonion/cli/co_ai/skills/builtin/commit/SKILL.md +63 -0
- connectonion/cli/co_ai/skills/builtin/review-pr/SKILL.md +76 -0
- connectonion/cli/co_ai/skills/loader.py +166 -0
- connectonion/cli/co_ai/skills/tool.py +46 -0
- connectonion/cli/co_ai/tools/__init__.py +92 -0
- connectonion/cli/co_ai/tools/ask_user.py +35 -0
- connectonion/cli/co_ai/tools/background.py +201 -0
- connectonion/cli/co_ai/tools/diff_writer.py +291 -0
- connectonion/cli/co_ai/tools/edit.py +89 -0
- connectonion/cli/co_ai/tools/glob.py +84 -0
- connectonion/cli/co_ai/tools/grep.py +158 -0
- connectonion/cli/co_ai/tools/load_guide.py +23 -0
- connectonion/cli/co_ai/tools/multi_edit.py +116 -0
- connectonion/cli/co_ai/tools/plan_mode.py +172 -0
- connectonion/cli/co_ai/tools/read.py +67 -0
- connectonion/cli/co_ai/tools/task.py +59 -0
- connectonion/cli/co_ai/tools/todo_list.py +159 -0
- connectonion/cli/co_ai/tools/write.py +126 -0
- connectonion/cli/commands/__init__.py +11 -1
- connectonion/cli/commands/ai_commands.py +34 -0
- connectonion/cli/commands/copy_commands.py +55 -6
- connectonion/cli/commands/create.py +20 -17
- connectonion/cli/commands/init.py +19 -22
- connectonion/cli/commands/project_cmd_lib.py +15 -0
- connectonion/cli/main.py +11 -0
- connectonion/console.py +15 -1
- connectonion/core/__init__.py +10 -1
- connectonion/core/agent.py +37 -16
- connectonion/core/exceptions.py +74 -0
- connectonion/core/llm.py +54 -6
- connectonion/core/tool_executor.py +32 -31
- connectonion/core/tool_factory.py +47 -10
- connectonion/debug/__init__.py +10 -1
- connectonion/debug/debug_explainer/__init__.py +10 -1
- connectonion/debug/execution_analyzer/__init__.py +10 -1
- connectonion/debug/execution_analyzer/execution_analysis.py +5 -2
- connectonion/debug/runtime_inspector/__init__.py +10 -1
- connectonion/docs/.package-ignore +6 -0
- connectonion/docs/README.md +2036 -0
- connectonion/docs/api.md +457 -0
- connectonion/docs/archive/001-ai-agent-is-just-prompt-plus-function.md +249 -0
- connectonion/docs/archive/README.md +53 -0
- connectonion/docs/archive/archive/consolidation-plan.md +72 -0
- connectonion/docs/archive/archive/core-principles-extracted.md +239 -0
- connectonion/docs/archive/archive/master-principles.md +222 -0
- connectonion/docs/archive/archive/principles.md +293 -0
- connectonion/docs/archive/archive/simplicity-principles.md +221 -0
- connectonion/docs/archive/attack-defense-insights.md +410 -0
- connectonion/docs/archive/business-model.md +305 -0
- connectonion/docs/archive/core-principles-unified.md +190 -0
- connectonion/docs/archive/discussion-journey.md +178 -0
- connectonion/docs/archive/economic-analysis.md +323 -0
- connectonion/docs/archive/features/01-share-and-find.md +256 -0
- connectonion/docs/archive/features/02-agent-authentication.md +93 -0
- connectonion/docs/archive/features/03-test-before-trust.md +71 -0
- connectonion/docs/archive/features/06-reliability-and-offline.md +197 -0
- connectonion/docs/archive/features/README.md +46 -0
- connectonion/docs/archive/features-roadmap.md +247 -0
- connectonion/docs/archive/mcp-comparison-insights.md +215 -0
- connectonion/docs/archive/migration-strategy.md +571 -0
- connectonion/docs/archive/mini-whitepaper.md +293 -0
- connectonion/docs/archive/network-protocol.md +394 -0
- connectonion/docs/archive/semantic-revolution.md +367 -0
- connectonion/docs/archive/technical-architecture.md +453 -0
- connectonion/docs/archive/the-semantic-insight.md +207 -0
- connectonion/docs/archive/threat-model.md +164 -0
- connectonion/docs/cli/README.md +805 -0
- connectonion/docs/cli/auth.md +46 -0
- connectonion/docs/cli/browser.md +235 -0
- connectonion/docs/cli/copy.md +232 -0
- connectonion/docs/cli/create.md +335 -0
- connectonion/docs/cli/init.md +431 -0
- connectonion/docs/co-directory-structure.md +214 -0
- connectonion/docs/concepts/agent.md +1078 -0
- connectonion/docs/concepts/events.md +699 -0
- connectonion/docs/concepts/llm_do.md +256 -0
- connectonion/docs/concepts/max_iterations.md +362 -0
- connectonion/docs/concepts/models.md +641 -0
- connectonion/docs/concepts/plugins.md +100 -0
- connectonion/docs/concepts/prompts.md +122 -0
- connectonion/docs/concepts/session.md +428 -0
- connectonion/docs/concepts/tools.md +512 -0
- connectonion/docs/concepts/transcribe.md +156 -0
- connectonion/docs/concepts/trust.md +291 -0
- connectonion/docs/connectonion.md +1256 -0
- connectonion/docs/debug/README.md +18 -0
- connectonion/docs/debug/auto_debug.md +1026 -0
- connectonion/docs/debug/console.md +129 -0
- connectonion/docs/debug/eval-format.md +178 -0
- connectonion/docs/debug/eval.md +230 -0
- connectonion/docs/debug/exceptions.md +307 -0
- connectonion/docs/debug/log.md +117 -0
- connectonion/docs/debug/xray.md +215 -0
- connectonion/docs/design-decisions/001-choosing-input-method.md +202 -0
- connectonion/docs/design-decisions/002-choosing-llm-function-name.md +202 -0
- connectonion/docs/design-decisions/003-choosing-trust-keyword.md +141 -0
- connectonion/docs/design-decisions/004-cli-create-flow.md +117 -0
- connectonion/docs/design-decisions/005-designing-agent-network-protocol.md +503 -0
- connectonion/docs/design-decisions/006-agent-address-format.md +305 -0
- connectonion/docs/design-decisions/007-authentication-backend-design.md +240 -0
- connectonion/docs/design-decisions/008-naming-is-hard.md +228 -0
- connectonion/docs/design-decisions/009-why-connect-function.md +167 -0
- connectonion/docs/design-decisions/010-cli-ux-progressive-disclosure.md +176 -0
- connectonion/docs/design-decisions/011-global-config-identity-management.md +357 -0
- connectonion/docs/design-decisions/012-tool-execution-separation.md +259 -0
- connectonion/docs/design-decisions/013-debug-and-logging-design.md +253 -0
- connectonion/docs/design-decisions/014-hook-system-design.md +510 -0
- connectonion/docs/design-decisions/015-interactive-auto-debug-design.md +837 -0
- connectonion/docs/design-decisions/016-why-no-zero-knowledge-proofs.md +358 -0
- connectonion/docs/design-decisions/017-session-logging-and-eval-format.md +120 -0
- connectonion/docs/design-decisions/018-event-api-naming.md +274 -0
- connectonion/docs/design-decisions/019-agent-lifecycle-design.md +655 -0
- connectonion/docs/design-decisions/020-trust-system-and-network-architecture.md +503 -0
- connectonion/docs/design-decisions/021-task-storage-jsonl-design.md +496 -0
- connectonion/docs/design-decisions/022-raw-asgi-implementation.md +273 -0
- connectonion/docs/examples.md +0 -0
- connectonion/docs/hook-system-options.md +364 -0
- connectonion/docs/integrations/README.md +12 -0
- connectonion/docs/integrations/auth.md +450 -0
- connectonion/docs/integrations/google.md +431 -0
- connectonion/docs/integrations/microsoft.md +370 -0
- connectonion/docs/network/README.md +14 -0
- connectonion/docs/network/connect.md +629 -0
- connectonion/docs/network/deploy.md +124 -0
- connectonion/docs/network/host.md +1087 -0
- connectonion/docs/network/io.md +538 -0
- connectonion/docs/network/protocol/agent-relay-protocol.md +495 -0
- connectonion/docs/network/protocol/announce-message.md +115 -0
- connectonion/docs/principles.md +124 -0
- connectonion/docs/quickstart.md +261 -0
- connectonion/docs/roadmap.md +81 -0
- connectonion/docs/templates/README.md +77 -0
- connectonion/docs/templates/meta-agent.md +152 -0
- connectonion/docs/templates/minimal.md +105 -0
- connectonion/docs/templates/playwright.md +130 -0
- connectonion/docs/templates/web-research.md +144 -0
- connectonion/docs/tui/README.md +95 -0
- connectonion/docs/tui/chat.md +181 -0
- connectonion/docs/tui/divider.md +63 -0
- connectonion/docs/tui/dropdown.md +83 -0
- connectonion/docs/tui/footer.md +44 -0
- connectonion/docs/tui/fuzzy.md +68 -0
- connectonion/docs/tui/input.md +84 -0
- connectonion/docs/tui/keys.md +77 -0
- connectonion/docs/tui/pick.md +71 -0
- connectonion/docs/tui/providers.md +89 -0
- connectonion/docs/tui/status_bar.md +67 -0
- connectonion/docs/useful_plugins/README.md +160 -0
- connectonion/docs/useful_plugins/calendar_plugin.md +68 -0
- connectonion/docs/useful_plugins/eval.md +89 -0
- connectonion/docs/useful_plugins/gmail_plugin.md +68 -0
- connectonion/docs/useful_plugins/image_result_formatter.md +74 -0
- connectonion/docs/useful_plugins/re_act.md +86 -0
- connectonion/docs/useful_plugins/shell_approval.md +69 -0
- connectonion/docs/useful_plugins/system_reminder.md +210 -0
- connectonion/docs/useful_prompts/README.md +127 -0
- connectonion/docs/useful_prompts/coding_agent.md +214 -0
- connectonion/docs/useful_tools/README.md +81 -0
- connectonion/docs/useful_tools/ask_user.md +103 -0
- connectonion/docs/useful_tools/diff_writer.md +158 -0
- connectonion/docs/useful_tools/get_emails.md +519 -0
- connectonion/docs/useful_tools/gmail.md +155 -0
- connectonion/docs/useful_tools/google_calendar.md +126 -0
- connectonion/docs/useful_tools/memory.md +506 -0
- connectonion/docs/useful_tools/microsoft_calendar.md +126 -0
- connectonion/docs/useful_tools/outlook.md +140 -0
- connectonion/docs/useful_tools/send_email.md +423 -0
- connectonion/docs/useful_tools/shell.md +115 -0
- connectonion/docs/useful_tools/slash_command.md +116 -0
- connectonion/docs/useful_tools/terminal.md +115 -0
- connectonion/docs/useful_tools/todo_list.md +272 -0
- connectonion/docs/useful_tools/web_fetch.md +150 -0
- connectonion/docs/vibe-coding-guide.md +97 -0
- connectonion/docs/windows-support.md +258 -0
- connectonion/logger.py +3 -3
- connectonion/network/__init__.py +19 -6
- connectonion/network/asgi/__init__.py +81 -0
- connectonion/network/asgi/http.py +205 -0
- connectonion/network/asgi/websocket.py +217 -0
- connectonion/network/connect.py +232 -185
- connectonion/network/host/__init__.py +59 -0
- connectonion/network/host/auth.py +191 -0
- connectonion/network/host/routes.py +135 -0
- connectonion/network/host/server.py +289 -0
- connectonion/network/host/session.py +78 -0
- connectonion/network/io/__init__.py +21 -0
- connectonion/network/{connection.py → io/base.py} +17 -42
- connectonion/network/io/websocket.py +55 -0
- connectonion/network/relay.py +37 -16
- connectonion/network/trust/__init__.py +30 -0
- connectonion/network/trust/factory.py +138 -0
- connectonion/network/{trust_agents.py → trust/prompts.py} +3 -3
- connectonion/network/{trust_functions.py → trust/tools.py} +2 -2
- connectonion/prompt_files/__init__.py +11 -1
- connectonion/prompt_files/react_acknowledge.md +26 -0
- connectonion/prompts.py +10 -1
- connectonion/tui/chat.py +10 -1
- connectonion/tui/divider.py +10 -1
- connectonion/tui/dropdown.py +10 -1
- connectonion/tui/footer.py +8 -0
- connectonion/tui/fuzzy.py +11 -1
- connectonion/tui/input.py +118 -70
- connectonion/tui/keys.py +133 -6
- connectonion/tui/providers.py +11 -1
- connectonion/tui/status_bar.py +10 -1
- connectonion/useful_events_handlers/__init__.py +8 -0
- connectonion/useful_events_handlers/reflect.py +19 -4
- connectonion/useful_plugins/__init__.py +2 -1
- connectonion/useful_plugins/eval.py +2 -2
- connectonion/useful_plugins/gmail_plugin.py +3 -3
- connectonion/useful_plugins/image_result_formatter.py +3 -3
- connectonion/useful_plugins/re_act.py +114 -28
- connectonion/useful_plugins/shell_approval.py +2 -2
- connectonion/useful_plugins/system_reminder.py +103 -0
- connectonion/useful_plugins/ui_stream.py +18 -133
- connectonion/useful_prompts/README.md +61 -0
- connectonion/useful_prompts/__init__.py +45 -0
- connectonion/useful_prompts/coding_agent/README.md +106 -0
- connectonion/useful_prompts/coding_agent/assembler.py +123 -0
- connectonion/useful_prompts/coding_agent/prompts/main.md +227 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/ask_user.md +61 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/background.md +57 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/edit.md +90 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/glob.md +52 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/grep.md +55 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/plan_mode.md +80 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/read.md +40 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/shell.md +67 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/task.md +51 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/todo.md +139 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/write.md +48 -0
- connectonion/useful_prompts/system-reminders/security-warning.md +14 -0
- connectonion/useful_prompts/system-reminders/test-reminder.md +11 -0
- connectonion/useful_tools/__init__.py +31 -4
- connectonion/useful_tools/ask_user.py +35 -0
- connectonion/useful_tools/bash.py +69 -0
- connectonion/useful_tools/diff_writer.py +186 -94
- connectonion/useful_tools/edit.py +102 -0
- connectonion/useful_tools/glob_files.py +97 -0
- connectonion/useful_tools/grep_files.py +171 -0
- connectonion/useful_tools/multi_edit.py +116 -0
- connectonion/useful_tools/read_file.py +73 -0
- connectonion/useful_tools/shell.py +50 -45
- connectonion/useful_tools/write_file.py +129 -0
- {connectonion-0.6.1.dist-info → connectonion-0.6.3.dist-info}/METADATA +10 -3
- connectonion-0.6.3.dist-info/RECORD +469 -0
- connectonion/cli/browser_agent/scroll_strategies.py +0 -276
- connectonion/network/asgi.py +0 -407
- connectonion/network/host.py +0 -616
- connectonion/network/trust.py +0 -166
- connectonion-0.6.1.dist-info/RECORD +0 -123
- /connectonion/cli/{docs → co_ai/prompts/connectonion}/connectonion.md +0 -0
- {connectonion-0.6.1.dist-info → connectonion-0.6.3.dist-info}/WHEEL +0 -0
- {connectonion-0.6.1.dist-info → connectonion-0.6.3.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
# Design Decision: Agent Lifecycle Design
|
|
2
|
+
|
|
3
|
+
**Status:** Implemented
|
|
4
|
+
**Date:** 2025-12-03
|
|
5
|
+
**Related:** [009-tool-execution-separation.md](./009-tool-execution-separation.md), [014-event-api-naming.md](./014-event-api-naming.md)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This document describes the complete lifecycle of an Agent from initialization through task completion. Understanding this lifecycle is essential for:
|
|
12
|
+
- Implementing event handlers correctly
|
|
13
|
+
- Debugging agent behavior
|
|
14
|
+
- Building plugins that work reliably
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## The Complete Lifecycle
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
22
|
+
│ AGENT INITIALIZATION │
|
|
23
|
+
│ Agent(name, tools, system_prompt, model, trust, ...) │
|
|
24
|
+
│ │
|
|
25
|
+
│ 1. Load system prompt (from string, file, or prompts/ folder) │
|
|
26
|
+
│ 2. Create Logger (terminal + .co/logs/ + .co/evals/) │
|
|
27
|
+
│ 3. Create trust agent (if trust parameter provided) │
|
|
28
|
+
│ 4. Initialize event registry │
|
|
29
|
+
│ 5. Register plugins and on_events handlers │
|
|
30
|
+
│ 6. Process tools → ToolRegistry │
|
|
31
|
+
│ 7. Create LLM via factory (based on model prefix) │
|
|
32
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
33
|
+
│
|
|
34
|
+
▼
|
|
35
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
36
|
+
│ agent.input(prompt) │
|
|
37
|
+
│ │
|
|
38
|
+
│ Entry point for task execution. Can be called multiple times │
|
|
39
|
+
│ for multi-turn conversations. │
|
|
40
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
41
|
+
│
|
|
42
|
+
▼
|
|
43
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
44
|
+
│ SESSION MANAGEMENT │
|
|
45
|
+
│ │
|
|
46
|
+
│ First call: │
|
|
47
|
+
│ - Create current_session with messages, trace, turn=0 │
|
|
48
|
+
│ - Add system prompt as first message │
|
|
49
|
+
│ - Start YAML session logging │
|
|
50
|
+
│ │
|
|
51
|
+
│ Subsequent calls: │
|
|
52
|
+
│ - Reuse existing session (multi-turn conversation) │
|
|
53
|
+
│ - Preserve message history │
|
|
54
|
+
│ │
|
|
55
|
+
│ Always: │
|
|
56
|
+
│ - Add user message to conversation │
|
|
57
|
+
│ - Increment turn counter │
|
|
58
|
+
│ - Add user_input trace entry │
|
|
59
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
60
|
+
│
|
|
61
|
+
▼
|
|
62
|
+
┌───────────────────────┐
|
|
63
|
+
│ @after_user_input │
|
|
64
|
+
│ │
|
|
65
|
+
│ Use cases: │
|
|
66
|
+
│ - Input validation │
|
|
67
|
+
│ - Preprocessing │
|
|
68
|
+
│ - Logging │
|
|
69
|
+
└───────────────────────┘
|
|
70
|
+
│
|
|
71
|
+
▼
|
|
72
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
73
|
+
│ ITERATION LOOP │
|
|
74
|
+
│ (max_iterations times, default=10) │
|
|
75
|
+
│ │
|
|
76
|
+
│ Each iteration: │
|
|
77
|
+
│ 1. Increment iteration counter │
|
|
78
|
+
│ 2. Get LLM decision │
|
|
79
|
+
│ 3. If no tool_calls → return response (exit loop) │
|
|
80
|
+
│ 4. Execute tools and record results │
|
|
81
|
+
│ 5. Continue to next iteration │
|
|
82
|
+
│ │
|
|
83
|
+
│ Exit conditions: │
|
|
84
|
+
│ - LLM returns content without tool_calls → return content │
|
|
85
|
+
│ - Max iterations reached → return "Task incomplete" message │
|
|
86
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
87
|
+
│
|
|
88
|
+
│
|
|
89
|
+
┌───────────────┴───────────────┐
|
|
90
|
+
│ LLM CALL PHASE │
|
|
91
|
+
│ │
|
|
92
|
+
│ ┌─────────────────────────┐ │
|
|
93
|
+
│ │ @before_llm │ │
|
|
94
|
+
│ │ │ │
|
|
95
|
+
│ │ Use cases: │ │
|
|
96
|
+
│ │ - Modify messages │ │
|
|
97
|
+
│ │ - Add context │ │
|
|
98
|
+
│ │ - Rate limiting │ │
|
|
99
|
+
│ └─────────────────────────┘ │
|
|
100
|
+
│ │ │
|
|
101
|
+
│ ▼ │
|
|
102
|
+
│ ┌─────────────────────────┐ │
|
|
103
|
+
│ │ LLM.complete() │ │
|
|
104
|
+
│ │ │ │
|
|
105
|
+
│ │ - Send messages │ │
|
|
106
|
+
│ │ - Include tool schemas │ │
|
|
107
|
+
│ │ - Receive response │ │
|
|
108
|
+
│ │ - Track token usage │ │
|
|
109
|
+
│ └─────────────────────────┘ │
|
|
110
|
+
│ │ │
|
|
111
|
+
│ ▼ │
|
|
112
|
+
│ ┌─────────────────────────┐ │
|
|
113
|
+
│ │ Add llm_call to trace │ │
|
|
114
|
+
│ │ │ │
|
|
115
|
+
│ │ Records: │ │
|
|
116
|
+
│ │ - model, timestamp │ │
|
|
117
|
+
│ │ - duration_ms │ │
|
|
118
|
+
│ │ - tool_calls_count │ │
|
|
119
|
+
│ │ - usage (tokens/cost) │ │
|
|
120
|
+
│ └─────────────────────────┘ │
|
|
121
|
+
│ │ │
|
|
122
|
+
│ ▼ │
|
|
123
|
+
│ ┌─────────────────────────┐ │
|
|
124
|
+
│ │ @after_llm │ │
|
|
125
|
+
│ │ │ │
|
|
126
|
+
│ │ Use cases: │ │
|
|
127
|
+
│ │ - Log LLM response │ │
|
|
128
|
+
│ │ - Modify tool_calls │ │
|
|
129
|
+
│ │ - Analytics │ │
|
|
130
|
+
│ └─────────────────────────┘ │
|
|
131
|
+
│ │ │
|
|
132
|
+
└──────────────┬────────────────┘
|
|
133
|
+
│
|
|
134
|
+
┌──────────────┴──────────────┐
|
|
135
|
+
│ │
|
|
136
|
+
▼ ▼
|
|
137
|
+
┌─────────────────┐ ┌────────────────────┐
|
|
138
|
+
│ No tool_calls │ │ Has tool_calls │
|
|
139
|
+
│ │ │ │
|
|
140
|
+
│ Return content │ │ Execute tools │
|
|
141
|
+
│ → @on_complete │ │ │
|
|
142
|
+
└─────────────────┘ └────────────────────┘
|
|
143
|
+
│
|
|
144
|
+
▼
|
|
145
|
+
┌────────────────────────────────────────────────┐
|
|
146
|
+
│ TOOL ROUND │
|
|
147
|
+
│ │
|
|
148
|
+
│ One LLM response can contain multiple tools. │
|
|
149
|
+
│ We call this group a "tool round." │
|
|
150
|
+
│ │
|
|
151
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
152
|
+
│ │ Add assistant message with tool_calls │ │
|
|
153
|
+
│ │ to conversation messages │ │
|
|
154
|
+
│ └─────────────────────────────────────────┘ │
|
|
155
|
+
│ │ │
|
|
156
|
+
│ ▼ │
|
|
157
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
158
|
+
│ │ @before_tools │ │
|
|
159
|
+
│ │ (fires ONCE) │ │
|
|
160
|
+
│ │ │ │
|
|
161
|
+
│ │ Use cases: │ │
|
|
162
|
+
│ │ - User approval before execution │ │
|
|
163
|
+
│ │ - Batch setup/preparation │ │
|
|
164
|
+
│ │ - Resource allocation │ │
|
|
165
|
+
│ └─────────────────────────────────────────┘ │
|
|
166
|
+
│ │ │
|
|
167
|
+
│ ▼ │
|
|
168
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
169
|
+
│ │ FOR EACH TOOL │ │
|
|
170
|
+
│ │ │ │
|
|
171
|
+
│ │ ┌───────────────────────────────────┐ │ │
|
|
172
|
+
│ │ │ @before_each_tool │ │ │
|
|
173
|
+
│ │ │ │ │ │
|
|
174
|
+
│ │ │ pending_tool available: │ │ │
|
|
175
|
+
│ │ │ - name, arguments, id │ │ │
|
|
176
|
+
│ │ │ │ │ │
|
|
177
|
+
│ │ │ Use cases: │ │ │
|
|
178
|
+
│ │ │ - Per-tool logging │ │ │
|
|
179
|
+
│ │ │ - Argument validation │ │ │
|
|
180
|
+
│ │ │ - Per-tool approval │ │ │
|
|
181
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
182
|
+
│ │ │ │ │
|
|
183
|
+
│ │ ▼ │ │
|
|
184
|
+
│ │ ┌───────────────────────────────────┐ │ │
|
|
185
|
+
│ │ │ TOOL EXECUTION │ │ │
|
|
186
|
+
│ │ │ │ │ │
|
|
187
|
+
│ │ │ 1. Inject xray context │ │ │
|
|
188
|
+
│ │ │ 2. Start timing │ │ │
|
|
189
|
+
│ │ │ 3. Execute tool_func(**args) │ │ │
|
|
190
|
+
│ │ │ 4. Record duration │ │ │
|
|
191
|
+
│ │ │ 5. Create trace entry │ │ │
|
|
192
|
+
│ │ │ 6. Clear xray context │ │ │
|
|
193
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
194
|
+
│ │ │ │ │
|
|
195
|
+
│ │ ▼ │ │
|
|
196
|
+
│ │ ┌───────────────────────────────────┐ │ │
|
|
197
|
+
│ │ │ Add tool result message │ │ │
|
|
198
|
+
│ │ │ {"role": "tool", ...} │ │ │
|
|
199
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
200
|
+
│ │ │ │ │
|
|
201
|
+
│ │ ▼ │ │
|
|
202
|
+
│ │ ┌───────────────────────────────────┐ │ │
|
|
203
|
+
│ │ │ (if error) @on_error │ │ │
|
|
204
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
205
|
+
│ │ │ │ │
|
|
206
|
+
│ │ ▼ │ │
|
|
207
|
+
│ │ ┌───────────────────────────────────┐ │ │
|
|
208
|
+
│ │ │ @after_each_tool │ │ │
|
|
209
|
+
│ │ │ │ │ │
|
|
210
|
+
│ │ │ WARNING: Do NOT add messages │ │ │
|
|
211
|
+
│ │ │ here - breaks Anthropic API! │ │ │
|
|
212
|
+
│ │ │ │ │ │
|
|
213
|
+
│ │ │ Use cases: │ │ │
|
|
214
|
+
│ │ │ - Per-tool logging │ │ │
|
|
215
|
+
│ │ │ - Metrics collection │ │ │
|
|
216
|
+
│ │ │ - Result caching │ │ │
|
|
217
|
+
│ │ └───────────────────────────────────┘ │ │
|
|
218
|
+
│ │ │ │ │
|
|
219
|
+
│ │ (repeat for next tool) │ │
|
|
220
|
+
│ └─────────────────────────────────────────┘ │
|
|
221
|
+
│ │ │
|
|
222
|
+
│ ▼ │
|
|
223
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
224
|
+
│ │ @after_tools │ │
|
|
225
|
+
│ │ (fires ONCE) │ │
|
|
226
|
+
│ │ │ │
|
|
227
|
+
│ │ SAFE to add messages here! │ │
|
|
228
|
+
│ │ All tool results are recorded. │ │
|
|
229
|
+
│ │ │ │
|
|
230
|
+
│ │ Use cases: │ │
|
|
231
|
+
│ │ - Reflection/reasoning injection │ │
|
|
232
|
+
│ │ - ReAct pattern implementation │ │
|
|
233
|
+
│ │ - Batch cleanup │ │
|
|
234
|
+
│ └─────────────────────────────────────────┘ │
|
|
235
|
+
│ │ │
|
|
236
|
+
└──────────────────────┼──────────────────────────┘
|
|
237
|
+
│
|
|
238
|
+
▼
|
|
239
|
+
(back to ITERATION LOOP)
|
|
240
|
+
│
|
|
241
|
+
▼
|
|
242
|
+
┌─────────────────────────────────────────────────┐
|
|
243
|
+
│ COMPLETION │
|
|
244
|
+
│ │
|
|
245
|
+
│ When LLM returns without tool_calls: │
|
|
246
|
+
│ 1. Calculate turn duration │
|
|
247
|
+
│ 2. Aggregate turn data for YAML session │
|
|
248
|
+
│ 3. Log turn to .co/evals/ │
|
|
249
|
+
│ 4. Fire @on_complete event │
|
|
250
|
+
│ 5. Return final response string │
|
|
251
|
+
└─────────────────────────────────────────────────┘
|
|
252
|
+
│
|
|
253
|
+
▼
|
|
254
|
+
┌───────────────────────┐
|
|
255
|
+
│ @on_complete │
|
|
256
|
+
│ │
|
|
257
|
+
│ Use cases: │
|
|
258
|
+
│ - Final logging │
|
|
259
|
+
│ - Cleanup │
|
|
260
|
+
│ - Notifications │
|
|
261
|
+
│ - Analytics │
|
|
262
|
+
└───────────────────────┘
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Key Concepts
|
|
268
|
+
|
|
269
|
+
### 1. Session Persistence
|
|
270
|
+
|
|
271
|
+
The `current_session` object persists across multiple `input()` calls, enabling multi-turn conversations:
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
agent = Agent("assistant")
|
|
275
|
+
|
|
276
|
+
# Turn 1
|
|
277
|
+
agent.input("What is 2+2?")
|
|
278
|
+
# Session created: turn=1, messages=[system, user1, assistant1]
|
|
279
|
+
|
|
280
|
+
# Turn 2 - conversation continues
|
|
281
|
+
agent.input("And what is that times 3?")
|
|
282
|
+
# Session reused: turn=2, messages=[..., user2, assistant2]
|
|
283
|
+
|
|
284
|
+
# Reset for fresh conversation
|
|
285
|
+
agent.reset_conversation()
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Session Structure:**
|
|
289
|
+
```python
|
|
290
|
+
current_session = {
|
|
291
|
+
'messages': [ # OpenAI-format conversation
|
|
292
|
+
{"role": "system", "content": "..."},
|
|
293
|
+
{"role": "user", "content": "..."},
|
|
294
|
+
{"role": "assistant", "content": "...", "tool_calls": [...]},
|
|
295
|
+
{"role": "tool", "tool_call_id": "...", "content": "..."},
|
|
296
|
+
],
|
|
297
|
+
'trace': [ # Execution history for debugging
|
|
298
|
+
{"type": "user_input", "turn": 1, "prompt": "..."},
|
|
299
|
+
{"type": "llm_call", "model": "...", "duration_ms": 123},
|
|
300
|
+
{"type": "tool_execution", "tool_name": "...", "timing": 45.2},
|
|
301
|
+
],
|
|
302
|
+
'turn': 1, # Conversation turn counter
|
|
303
|
+
'iteration': 3, # Current iteration within turn
|
|
304
|
+
'user_prompt': "...", # Current user prompt (for xray)
|
|
305
|
+
'pending_tool': {...}, # Available during before_each_tool only
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 2. The Iteration Loop
|
|
310
|
+
|
|
311
|
+
Each `input()` call runs an iteration loop:
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
Turn 1 (input("task"))
|
|
315
|
+
├── Iteration 1: LLM → tool_calls[search] → execute
|
|
316
|
+
├── Iteration 2: LLM → tool_calls[read_file] → execute
|
|
317
|
+
├── Iteration 3: LLM → content (no tools) → return
|
|
318
|
+
└── Total: 3 iterations
|
|
319
|
+
|
|
320
|
+
Turn 2 (input("followup"))
|
|
321
|
+
├── Iteration 1: LLM → content (no tools) → return
|
|
322
|
+
└── Total: 1 iteration
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Why Iterations?**
|
|
326
|
+
The LLM decides what to do next. After executing tools, it may need more tools, or it may have enough information to respond.
|
|
327
|
+
|
|
328
|
+
### 3. Tool Rounds vs Individual Tools
|
|
329
|
+
|
|
330
|
+
A single LLM response can request multiple tools. We call this a "tool round":
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
Iteration 1:
|
|
334
|
+
LLM Response: tool_calls = [search("python"), read_file("docs.md"), calculate(2+2)]
|
|
335
|
+
|
|
336
|
+
Tool Round:
|
|
337
|
+
@before_tools (once)
|
|
338
|
+
├── Tool 1: search("python")
|
|
339
|
+
│ ├── @before_each_tool
|
|
340
|
+
│ ├── execute
|
|
341
|
+
│ └── @after_each_tool
|
|
342
|
+
├── Tool 2: read_file("docs.md")
|
|
343
|
+
│ ├── @before_each_tool
|
|
344
|
+
│ ├── execute
|
|
345
|
+
│ └── @after_each_tool
|
|
346
|
+
└── Tool 3: calculate(2+2)
|
|
347
|
+
├── @before_each_tool
|
|
348
|
+
├── execute
|
|
349
|
+
└── @after_each_tool
|
|
350
|
+
@after_tools (once)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### 4. XRay Context Injection
|
|
354
|
+
|
|
355
|
+
During tool execution, the `xray` global provides execution context:
|
|
356
|
+
|
|
357
|
+
```python
|
|
358
|
+
from connectonion import xray
|
|
359
|
+
|
|
360
|
+
@xray # Decorator enables context access
|
|
361
|
+
def my_tool(query: str):
|
|
362
|
+
# Access runtime context
|
|
363
|
+
print(f"Agent: {xray.agent.name}")
|
|
364
|
+
print(f"Task: {xray.task}") # User's original prompt
|
|
365
|
+
print(f"Iteration: {xray.iteration}")
|
|
366
|
+
print(f"Previous tools: {xray.previous_tools}")
|
|
367
|
+
|
|
368
|
+
# View execution history
|
|
369
|
+
xray.trace() # Prints Rich-formatted trace
|
|
370
|
+
|
|
371
|
+
return "result"
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The context lifecycle:
|
|
375
|
+
1. `inject_xray_context()` before tool execution
|
|
376
|
+
2. Tool runs with access to `xray.*`
|
|
377
|
+
3. `clear_xray_context()` after tool completes
|
|
378
|
+
|
|
379
|
+
### 5. Message Ordering Constraint
|
|
380
|
+
|
|
381
|
+
**Critical:** Anthropic Claude requires tool results immediately after assistant tool_calls:
|
|
382
|
+
|
|
383
|
+
```python
|
|
384
|
+
# VALID sequence:
|
|
385
|
+
[
|
|
386
|
+
{"role": "assistant", "tool_calls": [{"id": "1"}, {"id": "2"}]},
|
|
387
|
+
{"role": "tool", "tool_call_id": "1", "content": "..."},
|
|
388
|
+
{"role": "tool", "tool_call_id": "2", "content": "..."},
|
|
389
|
+
{"role": "assistant", "content": "Reflection..."}, # After ALL tools
|
|
390
|
+
]
|
|
391
|
+
|
|
392
|
+
# INVALID - breaks Claude API:
|
|
393
|
+
[
|
|
394
|
+
{"role": "assistant", "tool_calls": [{"id": "1"}]},
|
|
395
|
+
{"role": "assistant", "content": "Thinking..."}, # Can't insert here!
|
|
396
|
+
{"role": "tool", "tool_call_id": "1", "content": "..."},
|
|
397
|
+
]
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Rule:** Only inject messages in `@after_tools`, never in `@after_each_tool`.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Event Summary
|
|
405
|
+
|
|
406
|
+
| Event | When | Frequency | Safe to Add Messages? |
|
|
407
|
+
|-------|------|-----------|----------------------|
|
|
408
|
+
| `@after_user_input` | After user prompt added | Once per input() | Yes |
|
|
409
|
+
| `@before_llm` | Before LLM call | Each iteration | Yes |
|
|
410
|
+
| `@after_llm` | After LLM response | Each iteration | Yes |
|
|
411
|
+
| `@before_tools` | Before first tool in round | Once per round | Yes |
|
|
412
|
+
| `@before_each_tool` | Before each tool | Per tool | No* |
|
|
413
|
+
| `@after_each_tool` | After each tool | Per tool | No |
|
|
414
|
+
| `@after_tools` | After all tools in round | Once per round | Yes |
|
|
415
|
+
| `@on_error` | When tool fails | Per error | No |
|
|
416
|
+
| `@on_complete` | Task finished | Once per input() | Yes |
|
|
417
|
+
|
|
418
|
+
\* `pending_tool` is available in `@before_each_tool` for inspection/validation.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Common Patterns
|
|
423
|
+
|
|
424
|
+
### Pattern 1: Reflection Plugin
|
|
425
|
+
|
|
426
|
+
Add reasoning after each tool round (ReAct pattern):
|
|
427
|
+
|
|
428
|
+
```python
|
|
429
|
+
from connectonion import Agent, after_tools, llm_do
|
|
430
|
+
|
|
431
|
+
@after_tools
|
|
432
|
+
def reflect(agent):
|
|
433
|
+
"""Generate reflection after tool execution."""
|
|
434
|
+
trace = agent.current_session['trace']
|
|
435
|
+
last_tools = [t for t in trace if t['type'] == 'tool_execution'][-3:]
|
|
436
|
+
|
|
437
|
+
reflection = llm_do(
|
|
438
|
+
f"What did we learn from: {last_tools}? One sentence.",
|
|
439
|
+
model="co/gemini-2.5-flash"
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
agent.current_session['messages'].append({
|
|
443
|
+
'role': 'assistant',
|
|
444
|
+
'content': f"Observation: {reflection}"
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
agent = Agent("researcher", tools=[search], on_events=[reflect])
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### Pattern 2: Human-in-the-Loop Approval
|
|
451
|
+
|
|
452
|
+
Require approval before executing tools:
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
from connectonion import Agent, before_tools
|
|
456
|
+
|
|
457
|
+
@before_tools
|
|
458
|
+
def require_approval(agent):
|
|
459
|
+
"""Ask for approval before tool execution."""
|
|
460
|
+
pending = agent.current_session.get('pending_tools', [])
|
|
461
|
+
print(f"\nAbout to execute {len(pending)} tool(s):")
|
|
462
|
+
for t in pending:
|
|
463
|
+
print(f" - {t['name']}({t['arguments']})")
|
|
464
|
+
|
|
465
|
+
response = input("Proceed? [y/n]: ")
|
|
466
|
+
if response.lower() != 'y':
|
|
467
|
+
raise Exception("User rejected tool execution")
|
|
468
|
+
|
|
469
|
+
agent = Agent("careful", tools=[delete_file], on_events=[require_approval])
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Pattern 3: Tool Execution Logging
|
|
473
|
+
|
|
474
|
+
Log every tool execution for debugging:
|
|
475
|
+
|
|
476
|
+
```python
|
|
477
|
+
from connectonion import Agent, before_each_tool, after_each_tool
|
|
478
|
+
import logging
|
|
479
|
+
|
|
480
|
+
logger = logging.getLogger('tools')
|
|
481
|
+
|
|
482
|
+
@before_each_tool
|
|
483
|
+
def log_start(agent):
|
|
484
|
+
tool = agent.current_session['pending_tool']
|
|
485
|
+
logger.info(f"START: {tool['name']}({tool['arguments']})")
|
|
486
|
+
|
|
487
|
+
@after_each_tool
|
|
488
|
+
def log_end(agent):
|
|
489
|
+
trace = agent.current_session['trace'][-1]
|
|
490
|
+
logger.info(f"END: {trace['tool_name']} ({trace['timing']:.1f}ms) -> {trace['status']}")
|
|
491
|
+
|
|
492
|
+
agent = Agent("logged", tools=[search], on_events=[log_start, log_end])
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Pattern 4: Context Window Management
|
|
496
|
+
|
|
497
|
+
Monitor and handle context limits:
|
|
498
|
+
|
|
499
|
+
```python
|
|
500
|
+
from connectonion import Agent, before_llm
|
|
501
|
+
|
|
502
|
+
@before_llm
|
|
503
|
+
def check_context(agent):
|
|
504
|
+
"""Warn if context is getting full."""
|
|
505
|
+
if agent.context_percent > 80:
|
|
506
|
+
print(f"WARNING: Context {agent.context_percent:.1f}% full")
|
|
507
|
+
# Could summarize old messages here
|
|
508
|
+
|
|
509
|
+
agent = Agent("context-aware", on_events=[check_context])
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Trace Entry Types
|
|
515
|
+
|
|
516
|
+
The trace records all execution events:
|
|
517
|
+
|
|
518
|
+
```python
|
|
519
|
+
# User input
|
|
520
|
+
{"type": "user_input", "turn": 1, "prompt": "...", "timestamp": 1701619200}
|
|
521
|
+
|
|
522
|
+
# LLM call
|
|
523
|
+
{
|
|
524
|
+
"type": "llm_call",
|
|
525
|
+
"model": "co/o4-mini",
|
|
526
|
+
"timestamp": 1701619201,
|
|
527
|
+
"duration_ms": 1234.5,
|
|
528
|
+
"tool_calls_count": 2,
|
|
529
|
+
"iteration": 1,
|
|
530
|
+
"usage": TokenUsage(input_tokens=150, output_tokens=50, cost=0.002)
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
# Tool execution
|
|
534
|
+
{
|
|
535
|
+
"type": "tool_execution",
|
|
536
|
+
"tool_name": "search",
|
|
537
|
+
"arguments": {"query": "python docs"},
|
|
538
|
+
"call_id": "call_abc123",
|
|
539
|
+
"result": "Found 5 results...",
|
|
540
|
+
"status": "success", # or "error", "not_found"
|
|
541
|
+
"timing": 45.2,
|
|
542
|
+
"iteration": 1,
|
|
543
|
+
"timestamp": 1701619202
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
# Error case
|
|
547
|
+
{
|
|
548
|
+
"type": "tool_execution",
|
|
549
|
+
"tool_name": "failing_tool",
|
|
550
|
+
"status": "error",
|
|
551
|
+
"error": "Connection timeout",
|
|
552
|
+
"error_type": "TimeoutError",
|
|
553
|
+
...
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## Logging Architecture
|
|
560
|
+
|
|
561
|
+
The lifecycle integrates with the logging system:
|
|
562
|
+
|
|
563
|
+
```
|
|
564
|
+
Agent(name="my_agent")
|
|
565
|
+
│
|
|
566
|
+
├─── Console (Rich terminal output)
|
|
567
|
+
│ └── Only if quiet=False (default)
|
|
568
|
+
│
|
|
569
|
+
├─── Plain Text Log
|
|
570
|
+
│ └── .co/logs/my_agent.log (always, unless log=False)
|
|
571
|
+
│
|
|
572
|
+
└─── YAML Session Log
|
|
573
|
+
└── .co/evals/my_agent_2025-12-03T10-30-00.yaml
|
|
574
|
+
|
|
575
|
+
YAML Session Structure:
|
|
576
|
+
─────────────────────────
|
|
577
|
+
agent: my_agent
|
|
578
|
+
model: co/o4-mini
|
|
579
|
+
started: 2025-12-03T10:30:00Z
|
|
580
|
+
turns:
|
|
581
|
+
- input: "Find Python tutorials"
|
|
582
|
+
model: co/o4-mini
|
|
583
|
+
duration_ms: 5234
|
|
584
|
+
tokens: 450
|
|
585
|
+
cost: 0.0045
|
|
586
|
+
tools_called: [search, read_file]
|
|
587
|
+
result: "Here are the top tutorials..."
|
|
588
|
+
messages: "[{...}, {...}]"
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
## Design Principles
|
|
594
|
+
|
|
595
|
+
### 1. Single Source of Truth
|
|
596
|
+
|
|
597
|
+
`current_session` is the only mutable state during execution. All components read/write to it:
|
|
598
|
+
- Messages accumulate in `current_session['messages']`
|
|
599
|
+
- Trace entries append to `current_session['trace']`
|
|
600
|
+
- Events access context via `agent.current_session`
|
|
601
|
+
|
|
602
|
+
### 2. Events Over Subclassing
|
|
603
|
+
|
|
604
|
+
Rather than subclassing Agent, use events:
|
|
605
|
+
|
|
606
|
+
```python
|
|
607
|
+
# Good: Use events
|
|
608
|
+
@after_tools
|
|
609
|
+
def my_logic(agent): ...
|
|
610
|
+
|
|
611
|
+
agent = Agent("name", on_events=[my_logic])
|
|
612
|
+
|
|
613
|
+
# Avoid: Subclassing
|
|
614
|
+
class MyAgent(Agent):
|
|
615
|
+
def _execute_and_record_tools(self, ...):
|
|
616
|
+
super()._execute_and_record_tools(...)
|
|
617
|
+
# my logic
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### 3. Fail Fast
|
|
621
|
+
|
|
622
|
+
Events propagate exceptions. No silent swallowing:
|
|
623
|
+
|
|
624
|
+
```python
|
|
625
|
+
@before_llm
|
|
626
|
+
def validate(agent):
|
|
627
|
+
if not agent.current_session['messages']:
|
|
628
|
+
raise ValueError("No messages!") # Propagates to caller
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
### 4. Always Collect, Conditionally Display
|
|
632
|
+
|
|
633
|
+
The trace always records everything. Display is controlled by `quiet` parameter:
|
|
634
|
+
|
|
635
|
+
```python
|
|
636
|
+
# Always recorded in trace and session
|
|
637
|
+
agent = Agent("name", quiet=True) # No console output
|
|
638
|
+
agent = Agent("name", quiet=False) # Console output (default)
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## Summary
|
|
644
|
+
|
|
645
|
+
The Agent lifecycle follows a clear pattern:
|
|
646
|
+
1. **Initialize** - Load config, create LLM, process tools
|
|
647
|
+
2. **Input** - Create/continue session, add user message
|
|
648
|
+
3. **Iterate** - LLM call → tool execution → repeat until done
|
|
649
|
+
4. **Complete** - Log session, fire on_complete, return result
|
|
650
|
+
|
|
651
|
+
Events provide hooks at every stage without requiring subclassing. The `current_session` object is the single source of truth, and the trace provides complete execution history for debugging and analytics.
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
*"The best architectures are those where you can predict what happens next."*
|