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,256 @@
|
|
|
1
|
+
# One-shot LLM Calls
|
|
2
|
+
|
|
3
|
+
Make direct LLM calls with optional structured output. Supports OpenAI, Google Gemini, and Anthropic models through a unified interface.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from connectonion import llm_do
|
|
9
|
+
|
|
10
|
+
# OpenAI (default)
|
|
11
|
+
answer = llm_do("What's 2+2?")
|
|
12
|
+
print(answer) # "4"
|
|
13
|
+
|
|
14
|
+
# Google Gemini
|
|
15
|
+
answer = llm_do("What's 2+2?", model="gemini-1.5-flash")
|
|
16
|
+
|
|
17
|
+
# Anthropic Claude
|
|
18
|
+
answer = llm_do("What's 2+2?", model="claude-3-5-haiku-20241022")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
That's it! One function for any LLM task across multiple providers.
|
|
22
|
+
|
|
23
|
+
## With Structured Output
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from pydantic import BaseModel
|
|
27
|
+
|
|
28
|
+
class Analysis(BaseModel):
|
|
29
|
+
sentiment: str
|
|
30
|
+
confidence: float
|
|
31
|
+
keywords: list[str]
|
|
32
|
+
|
|
33
|
+
result = llm_do(
|
|
34
|
+
"I absolutely love this product! Best purchase ever!",
|
|
35
|
+
output=Analysis
|
|
36
|
+
)
|
|
37
|
+
print(result.sentiment) # "positive"
|
|
38
|
+
print(result.confidence) # 0.98
|
|
39
|
+
print(result.keywords) # ["love", "best", "ever"]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Real Examples
|
|
43
|
+
|
|
44
|
+
### Extract Data from Text
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
class Invoice(BaseModel):
|
|
48
|
+
invoice_number: str
|
|
49
|
+
total_amount: float
|
|
50
|
+
due_date: str
|
|
51
|
+
|
|
52
|
+
invoice_text = """
|
|
53
|
+
Invoice #INV-2024-001
|
|
54
|
+
Total: $1,234.56
|
|
55
|
+
Due: January 15, 2024
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
invoice = llm_do(invoice_text, output=Invoice)
|
|
59
|
+
print(invoice.total_amount) # 1234.56
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Use Custom Prompts
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# With prompt file
|
|
66
|
+
summary = llm_do(
|
|
67
|
+
long_article,
|
|
68
|
+
system_prompt="prompts/summarizer.md" # Loads from file
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# With inline prompt
|
|
72
|
+
translation = llm_do(
|
|
73
|
+
"Hello world",
|
|
74
|
+
system_prompt="You are a translator. Translate to Spanish only."
|
|
75
|
+
)
|
|
76
|
+
print(translation) # "Hola mundo"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Quick Analysis Tool
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
def analyze_feedback(text: str) -> str:
|
|
83
|
+
"""Analyze customer feedback with structured output."""
|
|
84
|
+
|
|
85
|
+
class FeedbackAnalysis(BaseModel):
|
|
86
|
+
category: str # bug, feature, praise, complaint
|
|
87
|
+
priority: str # high, medium, low
|
|
88
|
+
summary: str
|
|
89
|
+
action_required: bool
|
|
90
|
+
|
|
91
|
+
analysis = llm_do(text, output=FeedbackAnalysis)
|
|
92
|
+
|
|
93
|
+
if analysis.action_required:
|
|
94
|
+
return f"🚨 {analysis.priority.upper()}: {analysis.summary}"
|
|
95
|
+
return f"📝 {analysis.category}: {analysis.summary}"
|
|
96
|
+
|
|
97
|
+
# Use in an agent
|
|
98
|
+
from connectonion import Agent
|
|
99
|
+
agent = Agent("support", tools=[analyze_feedback])
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Advanced Usage
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
result = llm_do(
|
|
106
|
+
input="Your text here",
|
|
107
|
+
output=YourModel, # Optional: Pydantic model for structure
|
|
108
|
+
system_prompt="instructions", # Optional: String or file path
|
|
109
|
+
model="gpt-4o-mini", # Optional: OpenAI, Gemini, Claude models
|
|
110
|
+
temperature=0.7, # Optional: Default is 0.1 (consistent)
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Supported Models
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
# OpenAI models (via managed keys)
|
|
118
|
+
llm_do("Hello", model="co/gpt-5")
|
|
119
|
+
llm_do("Hello", model="co/gpt-4o-mini")
|
|
120
|
+
llm_do("Hello", model="co/o4-mini")
|
|
121
|
+
|
|
122
|
+
# Google Gemini models (via managed keys)
|
|
123
|
+
llm_do("Hello", model="co/gemini-2.5-pro")
|
|
124
|
+
llm_do("Hello", model="co/gemini-2.5-flash")
|
|
125
|
+
|
|
126
|
+
# Anthropic Claude models (via managed keys)
|
|
127
|
+
llm_do("Hello", model="co/claude-sonnet-4-5")
|
|
128
|
+
llm_do("Hello", model="co/claude-haiku-4-5")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Structured Output Model Compatibility
|
|
132
|
+
|
|
133
|
+
When using `output=` with Pydantic models, note these compatibility differences:
|
|
134
|
+
|
|
135
|
+
| Provider | Structured Output Support |
|
|
136
|
+
|----------|--------------------------|
|
|
137
|
+
| **OpenAI** | All models |
|
|
138
|
+
| **Google Gemini** | All models |
|
|
139
|
+
| **Anthropic Claude** | Only 4.5/4.1 series (claude-sonnet-4-5, claude-opus-4-5, claude-opus-4-1, claude-haiku-4-5) |
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from pydantic import BaseModel
|
|
143
|
+
|
|
144
|
+
class Answer(BaseModel):
|
|
145
|
+
result: int
|
|
146
|
+
|
|
147
|
+
# Works with all providers
|
|
148
|
+
llm_do("What is 2+2?", output=Answer, model="co/gpt-4o-mini") # ✅
|
|
149
|
+
llm_do("What is 2+2?", output=Answer, model="co/gemini-2.5-flash") # ✅
|
|
150
|
+
llm_do("What is 2+2?", output=Answer, model="co/claude-sonnet-4-5") # ✅
|
|
151
|
+
|
|
152
|
+
# Legacy Claude models do NOT support structured output
|
|
153
|
+
# llm_do("What is 2+2?", output=Answer, model="co/claude-sonnet-4") # ❌
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Parameters
|
|
157
|
+
|
|
158
|
+
| Parameter | Type | Default | Description |
|
|
159
|
+
|-----------|------|---------|-------------|
|
|
160
|
+
| `input` | str | required | The input text/question |
|
|
161
|
+
| `output` | BaseModel | None | Pydantic model for structured output |
|
|
162
|
+
| `system_prompt` | str\|Path | None | System prompt (string or file path) |
|
|
163
|
+
| `model` | str | "gpt-4o-mini" | Model to use (supports OpenAI, Gemini, Claude) |
|
|
164
|
+
| `temperature` | float | 0.1 | Randomness (0=deterministic, 2=creative) |
|
|
165
|
+
|
|
166
|
+
## What You Get
|
|
167
|
+
|
|
168
|
+
- ✅ **One-shot execution** - Single LLM round, no loops
|
|
169
|
+
- ✅ **Type safety** - Full IDE autocomplete with Pydantic
|
|
170
|
+
- ✅ **Flexible prompts** - Inline strings or external files
|
|
171
|
+
- ✅ **Smart defaults** - Fast model, low temperature
|
|
172
|
+
- ✅ **Clean errors** - Clear messages when things go wrong
|
|
173
|
+
|
|
174
|
+
## Common Patterns
|
|
175
|
+
|
|
176
|
+
### Data Extraction
|
|
177
|
+
```python
|
|
178
|
+
class Person(BaseModel):
|
|
179
|
+
name: str
|
|
180
|
+
age: int
|
|
181
|
+
occupation: str
|
|
182
|
+
|
|
183
|
+
person = llm_do("John Doe, 30, software engineer", output=Person)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Quick Decisions
|
|
187
|
+
```python
|
|
188
|
+
is_urgent = llm_do("Customer says: My server is down!")
|
|
189
|
+
if "urgent" in is_urgent.lower():
|
|
190
|
+
escalate()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Format Conversion
|
|
194
|
+
```python
|
|
195
|
+
class JSONData(BaseModel):
|
|
196
|
+
data: dict
|
|
197
|
+
|
|
198
|
+
json_result = llm_do("Convert to JSON: name=John age=30", output=JSONData)
|
|
199
|
+
print(json_result.data) # {"name": "John", "age": 30}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Validation
|
|
203
|
+
```python
|
|
204
|
+
def validate_input(user_text: str) -> bool:
|
|
205
|
+
result = llm_do(
|
|
206
|
+
f"Is this valid SQL? Reply yes/no only: {user_text}",
|
|
207
|
+
temperature=0 # Maximum consistency
|
|
208
|
+
)
|
|
209
|
+
return result.strip().lower() == "yes"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Tips
|
|
213
|
+
|
|
214
|
+
1. **Use low temperature (0-0.3) for consistent results**
|
|
215
|
+
2. **Provide examples in your prompt for better accuracy**
|
|
216
|
+
3. **Use Pydantic models for anything structured**
|
|
217
|
+
4. **Cache prompts in files for reusability**
|
|
218
|
+
|
|
219
|
+
## Comparison with Agent
|
|
220
|
+
|
|
221
|
+
| Feature | `llm_do()` | `Agent()` |
|
|
222
|
+
|---------|---------|-----------|
|
|
223
|
+
| Purpose | One-shot calls | Multi-step workflows |
|
|
224
|
+
| Tools | No | Yes |
|
|
225
|
+
| Iterations | Always 1 | Up to max_iterations |
|
|
226
|
+
| State | Stateless | Maintains history |
|
|
227
|
+
| Best for | Quick tasks | Complex automation |
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
# Use llm_do() for simple tasks
|
|
231
|
+
answer = llm_do("What's the capital of France?")
|
|
232
|
+
|
|
233
|
+
# Use Agent for multi-step workflows
|
|
234
|
+
agent = Agent("assistant", tools=[search, calculate])
|
|
235
|
+
result = agent.input("Find the population and calculate density")
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Error Handling
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from connectonion import llm_do
|
|
242
|
+
from pydantic import ValidationError
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
result = llm_do("Analyze this", output=ComplexModel)
|
|
246
|
+
except ValidationError as e:
|
|
247
|
+
print(f"Output didn't match model: {e}")
|
|
248
|
+
except Exception as e:
|
|
249
|
+
print(f"LLM call failed: {e}")
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Next Steps
|
|
253
|
+
|
|
254
|
+
- Learn about [Agents](concepts/agent.md) for multi-step workflows
|
|
255
|
+
- Explore [Tools](concepts/tools.md) for extending agents
|
|
256
|
+
- See [xray](debug/xray.md) for debugging
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# max_iterations Guide
|
|
2
|
+
|
|
3
|
+
## What Are Iterations?
|
|
4
|
+
|
|
5
|
+
Think of iterations as "attempts" - how many times your agent can use tools to complete a task.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# Your agent tries to complete the task
|
|
9
|
+
# Iteration 1: "I need to search for info" → calls search tool
|
|
10
|
+
# Iteration 2: "Now I'll calculate something" → calls calculate tool
|
|
11
|
+
# Iteration 3: "Let me save the result" → calls save tool
|
|
12
|
+
# Done! Task completed in 3 iterations
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start - Super Simple
|
|
16
|
+
|
|
17
|
+
### The Basics (90% of what you need)
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from connectonion import Agent
|
|
21
|
+
|
|
22
|
+
# Default: 10 iterations (works for most tasks!)
|
|
23
|
+
agent = Agent("my_bot", tools=[search, calculate])
|
|
24
|
+
|
|
25
|
+
# That's it! Just use it:
|
|
26
|
+
result = agent.input("What's 2+2?") # Uses 1 iteration
|
|
27
|
+
result = agent.input("Search for Python tutorials") # Uses 1-2 iterations
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### When You Need More Power
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
# Complex tasks need more iterations
|
|
34
|
+
research_agent = Agent(
|
|
35
|
+
"researcher",
|
|
36
|
+
tools=[search, analyze, summarize],
|
|
37
|
+
max_iterations=25 # I need more attempts for complex research
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Quick Override for One Task
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
# Normal agent
|
|
45
|
+
agent = Agent("helper", tools=[...]) # Default 10
|
|
46
|
+
|
|
47
|
+
# But this ONE task is complex:
|
|
48
|
+
result = agent.input(
|
|
49
|
+
"Do something really complex",
|
|
50
|
+
max_iterations=30 # Just for this task!
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Real Examples - See It In Action
|
|
55
|
+
|
|
56
|
+
### Example 1: Simple Calculator Bot
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
def calculate(expression: str) -> float:
|
|
60
|
+
return eval(expression) # Simple math
|
|
61
|
+
|
|
62
|
+
# Calculator rarely needs many attempts
|
|
63
|
+
calc_bot = Agent(
|
|
64
|
+
"calculator",
|
|
65
|
+
tools=[calculate],
|
|
66
|
+
max_iterations=3 # Math is simple, 3 attempts is plenty
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# This works fine with just 1 iteration:
|
|
70
|
+
result = calc_bot.input("What's 15 * 8?")
|
|
71
|
+
print(result) # "The answer is 120"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example 2: Research Assistant
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
def search(query: str) -> str:
|
|
78
|
+
return f"Found 10 articles about {query}"
|
|
79
|
+
|
|
80
|
+
def summarize(text: str) -> str:
|
|
81
|
+
return f"Summary: {text[:100]}..."
|
|
82
|
+
|
|
83
|
+
def save_notes(content: str) -> str:
|
|
84
|
+
return "Notes saved!"
|
|
85
|
+
|
|
86
|
+
# Research needs more iterations
|
|
87
|
+
researcher = Agent(
|
|
88
|
+
"researcher",
|
|
89
|
+
tools=[search, summarize, save_notes],
|
|
90
|
+
max_iterations=20 # Research involves many steps
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# This might use 5-10 iterations:
|
|
94
|
+
result = researcher.input(
|
|
95
|
+
"Research quantum computing, summarize findings, and save notes"
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Example 3: What Happens When You Hit The Limit?
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
# Agent with very low limit
|
|
103
|
+
limited_bot = Agent("limited", tools=[...], max_iterations=2)
|
|
104
|
+
|
|
105
|
+
result = limited_bot.input("Do 5 different things")
|
|
106
|
+
print(result)
|
|
107
|
+
# Output: "Task incomplete: Maximum iterations (2) reached."
|
|
108
|
+
|
|
109
|
+
# Fix: Increase the limit!
|
|
110
|
+
result = limited_bot.input("Do 5 different things", max_iterations=10)
|
|
111
|
+
# Now it works!
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Cool Tricks & Advanced Patterns
|
|
115
|
+
|
|
116
|
+
### Trick 1: Auto-Retry with Higher Limit
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
def smart_input(agent, prompt, max_retries=3):
|
|
120
|
+
"""Automatically increases iterations if task fails."""
|
|
121
|
+
limits = [10, 25, 50] # Try these limits in order
|
|
122
|
+
|
|
123
|
+
for limit in limits:
|
|
124
|
+
result = agent.input(prompt, max_iterations=limit)
|
|
125
|
+
if "Maximum iterations" not in result:
|
|
126
|
+
return result # Success!
|
|
127
|
+
|
|
128
|
+
return "Task too complex even with 50 iterations"
|
|
129
|
+
|
|
130
|
+
# Use it:
|
|
131
|
+
agent = Agent("smart", tools=[...])
|
|
132
|
+
result = smart_input(agent, "Complex task") # Auto-adjusts!
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Trick 2: Dynamic Limit Based on Task
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
class SmartAgent:
|
|
139
|
+
def __init__(self, name, tools):
|
|
140
|
+
self.agent = Agent(name, tools)
|
|
141
|
+
|
|
142
|
+
def input(self, prompt):
|
|
143
|
+
# Detect task complexity from keywords
|
|
144
|
+
if "simple" in prompt or "what is" in prompt:
|
|
145
|
+
max_iter = 5
|
|
146
|
+
elif "analyze" in prompt or "research" in prompt:
|
|
147
|
+
max_iter = 30
|
|
148
|
+
else:
|
|
149
|
+
max_iter = 15 # Default
|
|
150
|
+
|
|
151
|
+
print(f"Using {max_iter} iterations for this task")
|
|
152
|
+
return self.agent.input(prompt, max_iterations=max_iter)
|
|
153
|
+
|
|
154
|
+
# Use it:
|
|
155
|
+
smart = SmartAgent("auto", tools=[...])
|
|
156
|
+
smart.input("What is 2+2?") # Uses 5 iterations
|
|
157
|
+
smart.input("Research and analyze market trends") # Uses 30 iterations
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Trick 3: Self-Adjusting Agent
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
class SelfAdjustingAgent:
|
|
164
|
+
"""Agent that learns optimal iterations from history."""
|
|
165
|
+
|
|
166
|
+
def __init__(self, name, tools):
|
|
167
|
+
self.agent = Agent(name, tools, max_iterations=10)
|
|
168
|
+
self.task_history = {}
|
|
169
|
+
|
|
170
|
+
def input(self, prompt):
|
|
171
|
+
# Start with learned limit or default
|
|
172
|
+
task_type = self._classify_task(prompt)
|
|
173
|
+
max_iter = self.task_history.get(task_type, 10)
|
|
174
|
+
|
|
175
|
+
# Try with current limit
|
|
176
|
+
result = self.agent.input(prompt, max_iterations=max_iter)
|
|
177
|
+
|
|
178
|
+
# If failed, increase and retry
|
|
179
|
+
while "Maximum iterations" in result and max_iter < 50:
|
|
180
|
+
max_iter += 10
|
|
181
|
+
print(f"Increasing to {max_iter} iterations...")
|
|
182
|
+
result = self.agent.input(prompt, max_iterations=max_iter)
|
|
183
|
+
|
|
184
|
+
# Remember what worked
|
|
185
|
+
if "Maximum iterations" not in result:
|
|
186
|
+
self.task_history[task_type] = max_iter
|
|
187
|
+
print(f"Learned: {task_type} tasks need {max_iter} iterations")
|
|
188
|
+
|
|
189
|
+
return result
|
|
190
|
+
|
|
191
|
+
def _classify_task(self, prompt):
|
|
192
|
+
# Simple classification
|
|
193
|
+
if "calculate" in prompt.lower():
|
|
194
|
+
return "math"
|
|
195
|
+
elif "research" in prompt.lower():
|
|
196
|
+
return "research"
|
|
197
|
+
else:
|
|
198
|
+
return "general"
|
|
199
|
+
|
|
200
|
+
# It learns over time!
|
|
201
|
+
agent = SelfAdjustingAgent("learner", tools=[...])
|
|
202
|
+
agent.input("Calculate something") # Learns math needs few iterations
|
|
203
|
+
agent.input("Research something") # Learns research needs more
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Trick 4: Budget-Aware Agent
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
class BudgetAgent:
|
|
210
|
+
"""Agent that tracks iteration 'budget' across multiple tasks."""
|
|
211
|
+
|
|
212
|
+
def __init__(self, name, tools, daily_iteration_budget=1000):
|
|
213
|
+
self.agent = Agent(name, tools)
|
|
214
|
+
self.budget = daily_iteration_budget
|
|
215
|
+
self.used = 0
|
|
216
|
+
|
|
217
|
+
def input(self, prompt, priority="normal"):
|
|
218
|
+
# Allocate iterations based on priority and remaining budget
|
|
219
|
+
remaining = self.budget - self.used
|
|
220
|
+
|
|
221
|
+
if priority == "high":
|
|
222
|
+
max_iter = min(50, remaining)
|
|
223
|
+
elif priority == "normal":
|
|
224
|
+
max_iter = min(20, remaining)
|
|
225
|
+
else: # low priority
|
|
226
|
+
max_iter = min(10, remaining)
|
|
227
|
+
|
|
228
|
+
if max_iter <= 0:
|
|
229
|
+
return "Iteration budget exhausted for today!"
|
|
230
|
+
|
|
231
|
+
# Track what we use
|
|
232
|
+
result = self.agent.input(prompt, max_iterations=max_iter)
|
|
233
|
+
|
|
234
|
+
# Count actual iterations used (simplified)
|
|
235
|
+
iterations_used = min(max_iter, 10) # Estimate
|
|
236
|
+
self.used += iterations_used
|
|
237
|
+
|
|
238
|
+
print(f"Used {iterations_used} iterations. {remaining - iterations_used} remaining today.")
|
|
239
|
+
return result
|
|
240
|
+
|
|
241
|
+
# Use it:
|
|
242
|
+
budget_agent = BudgetAgent("budgeted", tools=[...])
|
|
243
|
+
budget_agent.input("Important task", priority="high") # Gets up to 50
|
|
244
|
+
budget_agent.input("Regular task") # Gets up to 20
|
|
245
|
+
budget_agent.input("Low priority task", priority="low") # Gets up to 10
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Trick 5: Parallel Agents with Different Limits
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
def parallel_solve(prompt, tools):
|
|
252
|
+
"""Try multiple agents with different strategies in parallel."""
|
|
253
|
+
import concurrent.futures
|
|
254
|
+
|
|
255
|
+
strategies = [
|
|
256
|
+
("quick", 5), # Fast but might fail
|
|
257
|
+
("normal", 15), # Balanced
|
|
258
|
+
("thorough", 40) # Slow but thorough
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
def try_strategy(name, limit):
|
|
262
|
+
agent = Agent(f"{name}_solver", tools=tools, max_iterations=limit)
|
|
263
|
+
return name, agent.input(prompt)
|
|
264
|
+
|
|
265
|
+
# Run all strategies in parallel
|
|
266
|
+
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
267
|
+
futures = [
|
|
268
|
+
executor.submit(try_strategy, name, limit)
|
|
269
|
+
for name, limit in strategies
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
# Return first successful result
|
|
273
|
+
for future in concurrent.futures.as_completed(futures):
|
|
274
|
+
name, result = future.result()
|
|
275
|
+
if "Maximum iterations" not in result:
|
|
276
|
+
print(f"Strategy '{name}' succeeded!")
|
|
277
|
+
return result
|
|
278
|
+
|
|
279
|
+
return "All strategies failed"
|
|
280
|
+
|
|
281
|
+
# Use it:
|
|
282
|
+
result = parallel_solve("Complex problem", tools=[...])
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## When to Use Each Approach
|
|
286
|
+
|
|
287
|
+
### Keep It Simple (Most Common)
|
|
288
|
+
```python
|
|
289
|
+
# Just use defaults for most cases
|
|
290
|
+
agent = Agent("helper", tools=[...]) # 10 iterations is usually fine
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Set and Forget
|
|
294
|
+
```python
|
|
295
|
+
# Know your use case? Set it once
|
|
296
|
+
chatbot = Agent("chat", tools=[...], max_iterations=5) # Chatbots are simple
|
|
297
|
+
analyzer = Agent("analyzer", tools=[...], max_iterations=25) # Analysis is complex
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Dynamic Override
|
|
301
|
+
```python
|
|
302
|
+
# Override for specific tasks
|
|
303
|
+
agent = Agent("flex", tools=[...])
|
|
304
|
+
result = agent.input("normal task") # Uses default 10
|
|
305
|
+
result = agent.input("complex task", max_iterations=30) # Override when needed
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Quick Reference
|
|
309
|
+
|
|
310
|
+
### Decision Tree
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
Is your task...
|
|
314
|
+
├── Single tool, simple calculation? → 3-5 iterations
|
|
315
|
+
├── Multiple tools, standard complexity? → 8-10 iterations
|
|
316
|
+
├── Data analysis or file processing? → 10-15 iterations
|
|
317
|
+
├── Web automation or API calls? → 15-25 iterations
|
|
318
|
+
├── Research or complex workflows? → 20-30 iterations
|
|
319
|
+
└── Highly complex, many steps? → 30-50 iterations
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### How Many Iterations Do I Need?
|
|
323
|
+
|
|
324
|
+
| What You're Doing | Iterations | Example |
|
|
325
|
+
|-------------------|------------|---------|
|
|
326
|
+
| Simple Q&A | 3-5 | "What's the weather?" |
|
|
327
|
+
| Calculations | 5-10 | "Calculate my taxes" |
|
|
328
|
+
| Multi-step tasks | 10-20 | "Search and summarize" |
|
|
329
|
+
| Complex workflows | 20-40 | "Analyze all data and generate report" |
|
|
330
|
+
| Research projects | 30-50 | "Research topic from multiple sources" |
|
|
331
|
+
|
|
332
|
+
### Common Issues & Fixes
|
|
333
|
+
|
|
334
|
+
**"Maximum iterations reached" on simple tasks?**
|
|
335
|
+
```python
|
|
336
|
+
# Your tools might be failing. Check the history:
|
|
337
|
+
if "Maximum iterations" in result:
|
|
338
|
+
print(agent.history.records[-1].tool_calls) # See what went wrong
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Don't know what limit to set?**
|
|
342
|
+
```python
|
|
343
|
+
# Start with default, increase if needed:
|
|
344
|
+
agent = Agent("test", tools=[...]) # Start with 10
|
|
345
|
+
# If tasks fail, try max_iterations=20, then 30, etc.
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Want to prevent infinite loops?**
|
|
349
|
+
```python
|
|
350
|
+
# Set a low limit for untrusted tasks:
|
|
351
|
+
safe_agent = Agent("safe", tools=[...], max_iterations=5)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## The One-Minute Summary
|
|
355
|
+
|
|
356
|
+
1. **Most agents are fine with default `max_iterations=10`**
|
|
357
|
+
2. **Simple bots can use 5, complex ones need 20-30**
|
|
358
|
+
3. **Override per-task when needed: `agent.input(prompt, max_iterations=X)`**
|
|
359
|
+
4. **If you see "Maximum iterations reached", just increase the limit**
|
|
360
|
+
5. **Advanced: Build smart agents that adjust limits automatically**
|
|
361
|
+
|
|
362
|
+
That's it! You now know everything about iteration control. Start simple, adjust when needed! 🚀
|