Skip to content

feat(fakes): add fault injection and scripted Write tool_use to mock-anthropic - #2

Merged
MushuEE merged 5 commits into
agentexecutor:mainfrom
Lukeluds:feat/mock-anthropic-faults-tools
Nov 16, 2026
Merged

MushuEE merged 5 commits into
agentexecutor:mainfrom
Lukeluds:feat/mock-anthropic-faults-tools

Conversation

@Lukeluds

Copy link
Copy Markdown
Collaborator

Note: Stacked on #1 (see commit a1a71b4 for only this PR's diff; the PR diff will shrink automatically once #1 merges).

Extends fakes/mock-anthropic with runtime fault injection and multi-turn Write tool-call scripting for Claude Code E2E testing:

  • Fault modes (FAULT env or POST /_mock/config): 429 (rate limit with Retry-After: 1), 500 (server error for SDK retry testing), slow (delayed JSON/SSE), and truncated_sse (stream cut off before message_stop).
  • Scripted Write tool_use (TOOL_WRITE_PATH / TOOL_WRITE_CONTENT): Turn 1 emits a Write tool_use call (SSE or JSON); Turn 2 (once tool_result is returned) replies with REPLY_TEXT (end_turn).
  • Runtime configuration (POST /_mock/config): Allows switching fault/tool settings between test cases without restarting the pod, with validation (400 on unknown keys/faults) and reset on POST /_mock/reset.
  • Expands fakes/mock-anthropic/selftest.sh to cover all fault modes, config validation, and 2-turn Write tool_use.

@MushuEE MushuEE left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, and it lines up with the fakes/E2E plan (FAULT modes and scripted Write tool_use). I found three small bugs while poking at it locally; details inline. Both selftests pass on pr1 and pr2.

Comment thread fakes/mock-anthropic/mock_anthropic.py Resolved
Comment thread fakes/mock-anthropic/mock_anthropic.py Resolved
Comment thread fakes/mock-anthropic/mock_anthropic.py Resolved
@MushuEE MushuEE mentioned this pull request Nov 14, 2026
…_use

- Validate slow_delay (number, finite, >= 0) before applying any config so an
  invalid value returns 400 instead of half-applying and dropping the
  connection.
- Only emit the scripted Write tool_use when the request offers a Write tool,
  so tool-less side requests (quota probes, title generation) get text.
- Apply truncated_sse only as stream truncation for streaming requests; for
  non-streaming requests, send a JSON body cut off mid-way instead of SSE.
- Add selftest cases for all three and document behavior in the README.
MushuEE
MushuEE previously approved these changes Nov 16, 2026
@MushuEE
MushuEE merged commit 0ba3101 into agentexecutor:main Nov 16, 2026
2 checks passed
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