Skip to content

refactor: collapse /plan to a single LLM call - #41

Merged
haasonsaas merged 1 commit into
mainfrom
refactor/single-plan-llm-call
Jul 25, 2026
Merged

refactor: collapse /plan to a single LLM call#41
haasonsaas merged 1 commit into
mainfrom
refactor/single-plan-llm-call

Conversation

@haasonsaas

Copy link
Copy Markdown
Contributor

Summary

/plan made two LLM calls per request. The OpenAI Agents SDK planner produces the structured PRDPlan that actually builds the PRD; a second Responses API call produced free text stored as raw_plan that was never used to build the PRD or anything else. This PR removes the redundant call and everything that only existed to support it:

  • Removed the second LLM call from agent_pm/planner.py (openai_client.create_plan) and raw_plan from the result dict. Nothing else consumed raw_plan (models, traces, app response handling all verified by grep).
  • Removed the DSPy side path: deleted agent_pm/dspy_program.py, the USE_DSPY setting, the guidance-application code in planner.py, and the dspy_guidance_total metric. The guidance was computed after the planner agent already ran and only fed the deleted second call.
  • Removed the decorative YAML tool registry: deleted agent_pm/tools.py, config/tools.yaml, and the TOOL_CONFIG_PATH setting. The schemas were passed to the Responses API with no tool-call execution loop; the live planner path uses the Agents SDK @function_tool system (agent_sdk.py), which is untouched.
  • Updated .env.example and README accordingly; updated tests/test_planner.py and tests/test_dry_run_paths.py (dropped 5 DSPy/second-call tests, removed now-dead mocks, no unrelated assertions weakened).

Deliberately kept (audit said candidate for removal, but they're live)

  • agent_pm/clients/openai_client.py — used by procedure_runner.py for procedure model steps (and asserted in tests/test_connectors.py).
  • config/agents.yaml + AGENTS_CONFIG_PATH — loaded by agent_sdk.py::_load_agent_config_file to override planner/critic agent defaults; also referenced by the health endpoint and tests/test_agent_sdk.py.

Test plan

  • uv run ruff check . — pass
  • uv run ruff format --check . — pass (112 files)
  • uv run mypy agent_pm — pass (72 source files)
  • uv run pytest -q — 134 passed (was 139; −5 removed DSPy/second-call tests)
  • Repo-wide grep confirms no remaining references to dspy, raw_plan, tools.yaml, ToolRegistry, TOOL_CONFIG_PATH

/plan made two LLM calls per request: the Agents SDK planner produced
the structured PRDPlan that actually builds the PRD, and a second
Responses API call whose free-text output was stored as raw_plan but
never used to build the PRD or anything else. Remove the redundant
call and the machinery that only existed to feed it:

- drop openai_client.create_plan from the planner flow and raw_plan
  from the result dict (OpenAIClient itself stays: procedure_runner
  uses it for procedure model steps)
- delete the DSPy side path (dspy_program.py, USE_DSPY setting,
  dspy_guidance metric): its guidance was computed after the planner
  already ran and only fed the deleted second call
- delete the decorative YAML tool registry (tools.py, tools.yaml,
  TOOL_CONFIG_PATH): schemas were passed to the Responses API with no
  tool-call execution loop; the live planner path uses the Agents SDK
  @function_tool system instead

config/agents.yaml is kept: agent_sdk loads it to override planner and
critic agent defaults.
@haasonsaas
haasonsaas merged commit 07383f7 into main Jul 25, 2026
6 checks passed
@haasonsaas
haasonsaas deleted the refactor/single-plan-llm-call branch July 25, 2026 02:23
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.

1 participant