feat: add model-output corruption effects - #284
Open
venkatkrish543re wants to merge 8 commits into
Open
Conversation
Adds model-output corruption to the existing ChaosPlugin via a guarded MessageAddedEvent hook, alongside the P0 tool-chaos hooks. Effects: FormatCorruption (malformed JSON, truncation, schema violation, empty, garbage), Hallucination (confabulation), Refusal (full refusal), plus optional success-framing. The MessageAddedEvent callback is guarded to corrupt only final assistant responses (role==assistant, no toolUse blocks present) so destructive effects can't delete toolUse blocks mid-turn and break the agent loop. Includes 13 tests covering each effect and all guard conditions.
venkatkrish543re
had a problem deploying
to
manual-approval
June 24, 2026 21:58 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
June 24, 2026 21:58 — with
GitHub Actions
Failure
…ntions Folded model effects into effects.py with ModelEffect base parallel to ToolEffect Replaced ModelOutputCorruptionType enum with class-per-effect + ModelEffectUnion Removed apply_rate; chaos always applies when configured Dropped speculative untested effects (TOXIC_CONTENT, truncation, schema violation, etc.) Moved perturbation data onto owning effect classes Deleted model_effects.py / model_types.py / model_utils.py
venkatkrish543re
had a problem deploying
to
manual-approval
June 26, 2026 00:39 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
June 26, 2026 00:39 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
June 26, 2026 17:00 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
June 26, 2026 17:00 — with
GitHub Actions
Failure
venkatkrish543re
marked this pull request as ready for review
June 26, 2026 17:58
venkatkrish543re
had a problem deploying
to
manual-approval
June 26, 2026 17:59 — with
GitHub Actions
Failure
venkatkrish543re
pushed a commit
to venkatkrish543re/evals
that referenced
this pull request
Jun 27, 2026
Resolve Darren's 5 review comments on PR strands-agents#284: - FullRefusal becomes a true pre-model effect using BeforeModelCallEvent.cancel (strands-agents >= 1.45.0) - All other model effects (EmptyResponse, Confabulation, MalformedJson, SuccessFraming) remain post-model via MessageAddedEvent - Move model_effects from ChaosPlugin to ChaosCase as a sibling field (flat list, no tool-name dimension) - Add before_model_invocation hook; rename message_added to after_model_invocation - Add pre-effects guard in post hook to prevent double-corruption in mixed pre+post cases - Delete _map_text_in_blocks, replace with _apply_text_to_blocks - Rewrite tests for case-based construction via ContextVar - Add pre-hook integration test and mixed-case test 14 tests pass. Lint, format, and mypy clean.
venkatkrish543re
had a problem deploying
to
manual-approval
June 27, 2026 00:01 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
June 27, 2026 00:01 — with
GitHub Actions
Failure
- FullRefusal becomes a true pre-model effect using BeforeModelCallEvent.cancel (strands-agents >= 1.45.0) - All other model effects (EmptyResponse, Confabulation, MalformedJson, SuccessFraming) remain post-model via MessageAddedEvent - Move model_effects from ChaosPlugin to ChaosCase as a sibling field (flat list, no tool-name dimension) - Add before_model_invocation hook; rename message_added to after_model_invocation - Add pre-effects guard in post hook to prevent double-corruption in mixed pre+post cases - Delete _map_text_in_blocks, replace with _apply_text_to_blocks - Rewrite tests for case-based construction via ContextVar - Add pre-hook integration test and mixed-case test 14 tests pass.
venkatkrish543re
force-pushed
the
feat/p1-model-output
branch
from
June 27, 2026 00:21
596261c to
9d9328b
Compare
venkatkrish543re
had a problem deploying
to
manual-approval
July 9, 2026 06:57 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
July 9, 2026 06:57 — with
GitHub Actions
Failure
venkatkrish543re
force-pushed
the
feat/p1-model-output
branch
from
July 9, 2026 07:08
6b78561 to
e8cdc81
Compare
venkatkrish543re
had a problem deploying
to
manual-approval
July 9, 2026 07:08 — with
GitHub Actions
Failure
venkatkrish543re
had a problem deploying
to
manual-approval
July 9, 2026 07:08 — with
GitHub Actions
Failure
toolUse blocks (corrupts tool input JSON). Other post effects still
skip toolUse messages. Guard 2 checks
event.agent.tool_registry.dynamic_tools to identify structured-output
toolUse blocks. Only those are corrupted by MalformedJson; ordinary
mid-turn toolUse is left untouched.
- Change 2: Move model_effects into keyed effects dict
(effects={'model_effects': {'*': [...]}}) mirroring tool_effects.
Remove flat sibling field. '*' wildcard resolves to all models.
- Change 3: Rename _apply_to_blocks -> _apply_to_tool_blocks. Add
_apply_to_model_blocks for model post effects. Delete the short
_apply_text_to_blocks helper (folded into model blocks method).
Added _apply_malformed_json_selective helper that skips toolUse
blocks whose name is not in dynamic_tools.
- Change 4: EmptyResponse becomes pre-hook using cancel=' ' (single
space, truthy). Now two pre effects: FullRefusal and EmptyResponse.
Test calibration: propagation assertion used (structured_output_model
runs through normal event loop, fires MessageAddedEvent).
Tests: plain-named toolUse asserted UNCHANGED; only SO toolUse
corrupted; mixed message (regular + SO) selectively corrupts.
venkatkrish543re
force-pushed
the
feat/p1-model-output
branch
from
August 11, 2026 20:06
e8cdc81 to
670973c
Compare
venkatkrish543re
requested a deployment
to
manual-approval
August 11, 2026 20:10 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 11, 2026 20:10 — with
GitHub Actions
Waiting
jjbuck
requested changes
Aug 12, 2026
venkatkrish543re
requested a deployment
to
manual-approval
August 12, 2026 14:25 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 12, 2026 14:25 — with
GitHub Actions
Waiting
…l keys, semantic SO-tool detection
venkatkrish543re
force-pushed
the
feat/p1-model-output
branch
from
August 12, 2026 16:19
054b1bc to
dc98bba
Compare
venkatkrish543re
requested a deployment
to
manual-approval
August 12, 2026 16:29 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 12, 2026 16:37 — with
GitHub Actions
Waiting
jjbuck
requested changes
Aug 13, 2026
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 07:13 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 07:13 — with
GitHub Actions
Waiting
…ngle malform impl
venkatkrish543re
force-pushed
the
feat/p1-model-output
branch
from
August 13, 2026 08:53
fc1c460 to
7eb597b
Compare
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 08:53 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 08:53 — with
GitHub Actions
Waiting
…ed operations, trim public exports
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 21:20 — with
GitHub Actions
Waiting
venkatkrish543re
requested a deployment
to
manual-approval
August 13, 2026 21:20 — with
GitHub Actions
Waiting
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.
Description
Adds model-output corruption to the existing ChaosPlugin via a guarded MessageAddedEvent hook, alongside the tool-chaos hooks.
Effects: FormatCorruption (malformed JSON, EmptyResponse), Hallucination (confabulation), Refusal (full refusal), plus composable success-framing.
The MessageAddedEvent callback is guarded to corrupt only final assistant responses (role==assistant, no toolUse blocks present) so destructive effects can't delete toolUse blocks mid-turn and break the agent loop. Includes 12 tests covering each effect and all guard conditions.
Related Issues
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.