fix(qa): register fixture_generator and drive generator sessions via run_agent_session - #339
Conversation
…run_agent_session Fixture generation failed on every build with two non-fatal errors: - "Unknown agent type: 'fixture_generator'" — the agent type was never added to AGENT_CONFIGS, so create_client() rejected it. - "'ClaudeSDKClient' object has no attribute 'create_agent_session'" — the shared generator boilerplate called a method the SDK client does not have. Register fixture_generator in AGENT_CONFIGS (modeled on test_generator) and rewrite run_generator_session() to drive the client through run_agent_session() (agents/session.py) inside 'async with client' — the same session API the planner/coder/qa phases use. The agent role prompt is delivered as the leading message since the SDK client only carries the generic base system prompt. This fixes the fixture, e2e, and vitest generator paths plus test_generator's fixture step, which all share the boilerplate. Other inline client.create_agent_session() call sites (documentation_generator, migration_assistant, test_generator's writer sessions, agent_subprocess) have the identical bug and are tracked as a separate follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Oleg Miagkov <mrobenner@gmail.com>
|
Warning Review limit reached
More reviews will be available in 20 minutes and 56 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| # stub it when absent — mirroring how tests/conftest.py pre-mocks the Claude SDK. | ||
| if "numpy" not in sys.modules: | ||
| try: | ||
| import numpy # noqa: F401 |
…he phantom create_agent_session ClaudeSDKClient (claude_agent_sdk) has no `create_agent_session` method, so every inline call site raised `'ClaudeSDKClient' object has no attribute 'create_agent_session'` at runtime. The shared generator boilerplate (agents/_generator_base) was fixed in #339; this covers the remaining inline call sites it called out as a follow-up: - documentation_generator.run_documentation_generator_session - migration_assistant.run_migration_assistant - test_generator.run_test_generator_session (writer + coverage-improvement) - agent_subprocess.run_agent_session (isolated-subprocess wrapper) Each now drives the session through run_agent_session() (agents/session.py) inside `async with client` — the same API the planner/coder/qa phases use — and treats a returned status == "error" as failure. The agent role prompt is delivered as the leading message since the SDK client only carries the generic base system prompt. agent_subprocess imports the helper under an alias so it does not shadow its own run_agent_session() wrapper. Add tests/test_inline_generator_sessions.py (mirrors tests/test_fixture_generator_session.py: a fake async-context-manager client with no create_agent_session attribute, agents.session.run_agent_session patched as an AsyncMock, asserting it is awaited and the client is entered). Update the existing migration/test-generation suites that mocked the phantom method to drive the shared session helper instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Oleg Miagkov <mrobenner@gmail.com>
…he phantom create_agent_session (#341) * fix(agents): drive inline agent sessions via run_agent_session, not the phantom create_agent_session ClaudeSDKClient (claude_agent_sdk) has no `create_agent_session` method, so every inline call site raised `'ClaudeSDKClient' object has no attribute 'create_agent_session'` at runtime. The shared generator boilerplate (agents/_generator_base) was fixed in #339; this covers the remaining inline call sites it called out as a follow-up: - documentation_generator.run_documentation_generator_session - migration_assistant.run_migration_assistant - test_generator.run_test_generator_session (writer + coverage-improvement) - agent_subprocess.run_agent_session (isolated-subprocess wrapper) Each now drives the session through run_agent_session() (agents/session.py) inside `async with client` — the same API the planner/coder/qa phases use — and treats a returned status == "error" as failure. The agent role prompt is delivered as the leading message since the SDK client only carries the generic base system prompt. agent_subprocess imports the helper under an alias so it does not shadow its own run_agent_session() wrapper. Add tests/test_inline_generator_sessions.py (mirrors tests/test_fixture_generator_session.py: a fake async-context-manager client with no create_agent_session attribute, agents.session.run_agent_session patched as an AsyncMock, asserting it is awaited and the client is entered). Update the existing migration/test-generation suites that mocked the phantom method to drive the shared session helper instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Oleg Miagkov <mrobenner@gmail.com> * Potential fix for pull request finding 'CodeQL / Unused import' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --------- Signed-off-by: Oleg Miagkov <mrobenner@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>



Problem
The fixture-generation step in the QA/validation path failed on every build (non-fatally — it logged
Fixture generation failedand continued). Two errors fired fromagents/fixture_generator.pyvia the sharedrun_generator_sessionboilerplate:Unknown agent type: 'fixture_generator'— the agent type was never added toAGENT_CONFIGS, socreate_client()rejected it.'ClaudeSDKClient' object has no attribute 'create_agent_session'— the generator boilerplate called a method the SDK client does not have. The canonical session driver isrun_agent_session(client, …)inagents/session.py(used by planner/coder/qa), which returns a 4-tuple and runs insideasync with client:.Fix
agents/tools_pkg/models.py— registerfixture_generatorinAGENT_CONFIGS(modeled ontest_generator: read/write/bash tooling, no browser). Verifiede2e_generator,test_generator,documentation_generator, andmigration_assistantwere already registered, and that every boilerplate consumer passes a registered type with an existing prompt file.agents/_generator_base.py— replaceclient.create_agent_session(...)withrun_agent_session(client, message, spec_dir, …)insideasync with client:. The agent's.mdrole prompt is delivered as the leading message (the SDK client only carries the generic base system prompt), matching how the planner/performance_profiler sessions pass prompts.Because the boilerplate is shared, this also repairs the e2e and vitest generators and
test_generator's fixture step.Tests
New
tests/test_fixture_generator_session.py(9 tests):fixture_generatoragent type resolves viaget_agent_config/get_allowed_tools/get_required_mcp_servers, and the sibling generators remain registered.run_generator_sessionawaits the realrun_agent_sessionwith the prompt-as-message, insideasync with client, against a fake client that has nocreate_agent_session— so a regression fails loudly.Unknown agent typesymptom.Out of scope (follow-up)
Four identical
client.create_agent_session()sites remain in separate inline session code (not the shared boilerplate):documentation_generator.py:209,migration_assistant.py:277,test_generator.py:1601/:1722(the test-writer sessions), andagent_subprocess.py:180. Same bug, same fix recipe — tracked separately to keep this PR focused.🤖 Generated with Claude Code