Skip to content

fix(qa): register fixture_generator and drive generator sessions via run_agent_session - #339

Merged
OBenner merged 1 commit into
developfrom
claude/fervent-ellis-540760
Jun 13, 2026
Merged

fix(qa): register fixture_generator and drive generator sessions via run_agent_session#339
OBenner merged 1 commit into
developfrom
claude/fervent-ellis-540760

Conversation

@OBenner

@OBenner OBenner commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Problem

The fixture-generation step in the QA/validation path failed on every build (non-fatally — it logged Fixture generation failed and continued). Two errors fired from agents/fixture_generator.py via the shared run_generator_session boilerplate:

  1. Unknown agent type: 'fixture_generator' — the agent type was never added to AGENT_CONFIGS, so create_client() rejected it.
  2. 'ClaudeSDKClient' object has no attribute 'create_agent_session' — the generator boilerplate called a method the SDK client does not have. The canonical session driver is run_agent_session(client, …) in agents/session.py (used by planner/coder/qa), which returns a 4-tuple and runs inside async with client:.

Fix

  • agents/tools_pkg/models.py — register fixture_generator in AGENT_CONFIGS (modeled on test_generator: read/write/bash tooling, no browser). Verified e2e_generator, test_generator, documentation_generator, and migration_assistant were already registered, and that every boilerplate consumer passes a registered type with an existing prompt file.
  • agents/_generator_base.py — replace client.create_agent_session(...) with run_agent_session(client, message, spec_dir, …) inside async with client:. The agent's .md role 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):

  • The fixture_generator agent type resolves via get_agent_config / get_allowed_tools / get_required_mcp_servers, and the sibling generators remain registered.
  • run_generator_session awaits the real run_agent_session with the prompt-as-message, inside async with client, against a fake client that has no create_agent_session — so a regression fails loudly.
  • Error-path propagation and the original Unknown agent type symptom.
33 passed   (9 new + 24 existing tests/test_agent_configs.py — no regressions)

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), and agent_subprocess.py:180. Same bug, same fix recipe — tracked separately to keep this PR focused.

🤖 Generated with Claude Code

…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>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@OBenner, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a9cf5591-883f-476b-9998-92ea87d00aa6

📥 Commits

Reviewing files that changed from the base of the PR and between eb86b8f and 26f06c9.

📒 Files selected for processing (3)
  • apps/backend/agents/_generator_base.py
  • apps/backend/agents/tools_pkg/models.py
  • tests/test_fixture_generator_session.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fervent-ellis-540760

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added area/backend bug Something isn't working size/M labels Jun 13, 2026
@sonarqubecloud

Copy link
Copy Markdown

# 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
@OBenner
OBenner merged commit dd5673e into develop Jun 13, 2026
20 checks passed
@OBenner
OBenner deleted the claude/fervent-ellis-540760 branch June 13, 2026 06:03
OBenner added a commit that referenced this pull request Jun 13, 2026
…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>
OBenner added a commit that referenced this pull request Jun 14, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend bug Something isn't working size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants