feat: refactor plan-execute agentic orchestration in custom MCP client#154
Merged
DhavalRepo18 merged 25 commits intomainfrom Feb 19, 2026
Merged
feat: refactor plan-execute agentic orchestration in custom MCP client#154DhavalRepo18 merged 25 commits intomainfrom
DhavalRepo18 merged 25 commits intomainfrom
Conversation
Empty commit to open tracking PR for refactoring AgentHive orchestration into a custom MCP client. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
2108550 to
a50aa22
Compare
- PlanStep, Plan (with topological resolved_order), StepResult, OrchestratorResult dataclasses in models.py - Abstract LLMBackend interface and WatsonXLLM concrete implementation (integer model IDs: 16=llama-4-maverick, 19=granite-3-3-8b) Closes #151 (partial) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Planner (maps AgentHive PlanningWorkflow): - LLM decomposes question into #Task/#Agent/#Dependency/#ExpectedOutput steps - parse_plan() reuses the same regex format as PlanningWorkflow.generate_steps() Executor (maps AgentHive SequentialWorkflow + ReactAgent): - Per-step: queries assigned MCP server for tools via stdio transport - LLM selects the best tool and generates its arguments - Calls the tool via mcp.ClientSession / stdio_client - Handles unknown agents, tool call errors, and direct answers from context Orchestrator (PlanExecuteOrchestrator): - Discover → Plan → Execute → Summarise pipeline - server_paths is injectable for testing / future server additions Closes #151 (partial) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Tests (36 total across 3 modules): - test_models: Plan.resolved_order() topological sort (no deps, linear, diamond, parallel, empty), get_step(), StepResult.success - test_planner: parse_plan() regex parsing for tasks/agents/deps/outputs, Planner.generate_plan() prompt injection and LLM delegation - test_orchestrator: full orchestrator run, unknown agent error path, direct-answer (tool=null) path; Executor unknown-agent; _parse_tool_call variants (plain JSON, markdown fence, embedded JSON, unrecoverable) Bug fix: Executor.__init__ used server_paths or DEFAULT_SERVER_PATHS which silently ignored an explicitly passed empty dict; changed to if server_paths is None check. Closes #151 (partial) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
ibm-watsonx-ai is not required for the core orchestration framework or tests (which use mock LLMs). Add it as an optional extra so production deployments can opt in: pip install "assetopsbench-mcp[watsonx]" Closes #151 (partial) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- mcp/client/ → mcp/plan_execute/ (package rename) - orchestrator.py → runner.py; PlanExecuteOrchestrator → PlanExecuteRunner - test_orchestrator.py → test_runner.py - Update all imports and mock patch paths throughout No functional changes. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- Replace the [WIP] stub with a full Plan-Execute Runner section: how it works (4-step loop), usage example, bring-your-own-LLM, adding more MCP servers via server_paths - Update Running Tests to include plan_execute/tests/ commands and a combined one-liner for the full non-integration suite - Update Architecture diagram to reflect the plan_execute package structure (Planner → Executor → Summariser → MCP servers) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
plan_execute/cli.py: - plan-execute <question> runs the full plan-execute workflow - --model-id INT select WatsonX model (default: 16) - --server NAME=PATH register additional MCP servers (repeatable) - --show-plan print the generated plan before execution - --show-history print each step result after execution - --json emit answer + plan + history as JSON pyproject.toml: - Register plan-execute = "plan_execute.cli:main" under [project.scripts] - Add hatchling build-system with packages = ["plan_execute"] to fix multi-package discovery error and enable entry point installation - Add tool.uv.package = true README: document CLI flags, examples, and python-api usage side by side Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Treat mcp/ as the source directory (like src/) with the repo root as the project entrypoint. All uv/hatchling/pytest commands now run from root. Moved to repo root: mcp/pyproject.toml → pyproject.toml mcp/uv.lock → uv.lock mcp/.python-version → .python-version mcp/docker-compose.yaml → docker-compose.yaml Updated pyproject.toml: - packages = ["mcp/plan_execute"] (was "plan_execute") - pythonpath = ["mcp"] (was ["."]) - readme = "mcp/README.md" Updated mcp/README.md: - All uv/pytest commands use mcp/ prefix (e.g. mcp/servers/iot/...) - Claude Desktop --project flag points to repo root Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- mcp/README.md → INSTRUCTIONS.md (repo root) - pyproject.toml: readme = "INSTRUCTIONS.md" - README.md: add MCP Environment section under AI Agents pointing to INSTRUCTIONS.md Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
- docker-compose.yaml → mcp/couchdb/docker-compose.yaml - Update volume bind-mount paths (drop couchdb/ prefix now that the compose file is colocated with couchdb_setup.sh and sample_data/) - INSTRUCTIONS.md: all docker compose commands use -f mcp/couchdb/docker-compose.yaml Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
ibm_watsonx_ai is incompatible with Python 3.14 — its StrEnum subclass calls super().__init__(*args, **kwargs) which Python 3.14 rejects with TypeError: object.__init__() takes exactly one argument. WatsonXLLM now uses requests (already a core dep) to call the WatsonX REST API directly: - IAM token endpoint for auth (with 60-second early-refresh cache) - /ml/v1/text/generation for inference Drop ibm-watsonx-ai from optional deps in pyproject.toml and remove the install step from INSTRUCTIONS.md — no extra install needed. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
…eference, and clearer structure Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
…all per run) Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
e92eb1c to
8e5f597
Compare
4 tasks
Collaborator
Author
Checklist evaluationAll four items from the PR description are complete:
Marking ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #151 — refactors the plan-execute agentic orchestration layer to run within a custom MCP client, replacing/augmenting the existing
AgentHiveframework.Motivation
The current
src/agent_hive/plan-and-execute sequential workflow relies on bespoke orchestration logic. Moving this into a custom MCP client enables:Checklist
References
src/agent_hive/mcp-refactorbranch