Skip to content

feat(agents): lazy-start stopped experts on first invocation - #2471

Open
huangcheng wants to merge 5 commits into
TencentCloud:developfrom
huangcheng:feat/agent-mcp-lazy-start
Open

huangcheng wants to merge 5 commits into
TencentCloud:developfrom
huangcheng:feat/agent-mcp-lazy-start

Conversation

@huangcheng

Copy link
Copy Markdown
Contributor

Summary

  • Adds AgentManager.ensure_loaded() and uses it from stream / call / resume_hitl and Agent MCP call_expert / resume_expert.
  • Stopped experts auto-start on first real invocation (init_workspace=False, per-agent lifecycle lock). failed agents are not retried.
  • Behavior change: an explicitly stop()ped expert will come back on the next call (same as “open chat” implying use).

Depends on

  • The fail-fast / error-classification PR (fix/agent-mcp-stopped-expert-errors) — this branch is stacked on top of it. Merge that first (or merge this after rebase once that lands).

Test plan

  • uv run pytest tests/unit/agents/test_ensure_loaded.py tests/unit/agent_mcp -q
  • Stop an expert → MCP call_octop_expert → expert becomes running and turn completes
  • Failed expert still returns AGENT_FAILED without a second start attempt
  • Concurrent first calls only start once (lifecycle lock)

Stopped experts were raising harness KeyError and surfacing as a misleading
model-call failure. Precheck runtime via get_agent, split AGENT_DISABLED,
classify KeyError stream errors, and expose MCP error codes.
External MCP/dashboard calls should not require clients to understand Octop's
start/stop state machine. ensure_loaded starts stopped agents on demand while
leaving failed agents alone so configuration errors stay visible.
@jubaoliang

Copy link
Copy Markdown
Collaborator

🔍 Automated Review Findings

  • ❌ CI Workflow failed: fix the failing checks before requesting re-review

Please address the above and @ me for re-review.

stream/resume_hitl now precheck via get_agent; SimpleNamespace fakes without
it raised AttributeError and left serialization tests waiting forever (CI 6h).
@huangcheng

Copy link
Copy Markdown
Contributor Author

@jubaoliang Same root cause as #2470: CI Test step hung at ~90% for 6h on stream/resume unit fakes missing get_agent after the runtime precheck. Fixed in 54c084e. Please re-review once CI is green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants