fix: Agent event dispatching#214
Merged
monoxgas merged 3 commits intoNov 13, 2025
Merged
Conversation
…small bugs. Added RegexRefAgent mixin.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for the Agent system and refactors the agent execution logic. Key changes include adding a new RegexRefAgent mixin, fixing event dispatching for hooks, improving step counting logic, and moving AgentStopReason to a more appropriate module.
- Added 629 lines of comprehensive tests for Agent initialization, execution, hooks, and reactions
- Refactored agent execution flow to properly dispatch
Reactedevents and handle stalling conditions - Introduced
RegexRefAgentmixin for dynamic regex-based references in tool arguments
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_agent.py | New comprehensive test suite covering Agent initialization, execution, hooks, reactions, and edge cases |
| pyproject.toml | Added PERF exclusion for test files to allow performance-related patterns in tests |
| dreadnode/agent/result.py | Added stop_reason field to AgentResult and moved AgentStopReason type definition here |
| dreadnode/agent/events.py | Moved AgentStopReason import and added quotes around forward reference |
| dreadnode/agent/agent.py | Major refactor: removed hook mapping, improved event dispatching, added model_post_init re-triggering, introduced RegexRefAgent, fixed step counting logic |
| docs/sdk/agent.mdx | Updated documentation for TaskAgent and added RegexRefAgent documentation |
Comments suppressed due to low confidence (1)
dreadnode/agent/agent.py:706
- Inconsistent step counting: The log message uses
step - 1but the AgentResult at line 732 usesstepdirectly. This creates a mismatch where the logged steps value differs from the result.steps value. Both should use the same value for consistency. Based on the loop logic starting from 0 and incrementing at the beginning,stepalready contains the correct final step count, so the- 1here appears incorrect.
f"steps={step - 1}, "
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mkultraWasHere
pushed a commit
that referenced
this pull request
Nov 20, 2025
* Added AgentEnd/Reacted to dispatch. Added agent tests and fixed some small bugs. Added RegexRefAgent mixin. * Fixing up tests and configure() behavior during tests.
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.
Generated Summary:
RegexRefAgentmixin for dynamic text referencing using regex patterns in tool calls, improving tool call efficiency by reducing repetition.{find:<pattern>}syntax to guide users on its usage.Agentclass with themodel_post_initcall during thewith_method to ensure consistency in initialization.hooksmechanism inAgentto streamline behavior and remove redundant code, potentially improving performance and clarity.TaskAgentinitialization to ensure required tools and hooks are appended only if they are not already present.max_stepshandling logic to correct the finishing step calculation and improve overall agent flow control.These changes collectively enhance the functionality and reliability of the agents within the SDK.
This summary was generated with ❤️ by rigging