Repository navigation
test: type-check agent hook and confirmation tests - #12681
Merged
Merged
Conversation
Koushik890
requested review from
anakin87
and
a lite review from Copilot
and removed request for
a team
September 9, 2026 13:47
Contributor
|
@Koushik890 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are test/type-check focused and low-risk, with only a minor naming cleanup suggested.
Pull request overview
- Extends the project’s
hatch run test:typesmypy target to include the agent hooks and human-in-the-loop agent tests, ensuring these test modules are type-checked in CI going forward.
Changes:
- Add
test/components/agents/test_agent_hooks.pyandtest/components/agents/test_agent_hitl.pyto the mypytypesscript inpyproject.toml. - Update agent hook tests to satisfy the
Hookprotocol requirements for serialization (to_dict/from_dict) and tighten serde assertions for hooks. - Update HITL tests with more precise typing for confirmation strategy mappings and use
pytest’smonkeypatchfor method mocking.
File summaries
| File | Description |
|---|---|
test/components/agents/test_agent_hooks.py |
Makes test hooks conform to the hook protocol/serialization expectations and adds stricter post-deserialization assertions for hook types. |
test/components/agents/test_agent_hitl.py |
Aligns HITL test typing with the confirmation strategy API and updates mocking to use monkeypatch. |
pyproject.toml |
Adds the two agent test modules to the standard mypy types target so CI type-checks them. |
Review details
Suppressed comments (1)
test/components/agents/test_agent_hitl.py:171
Hookis imported for typing, but this test later assigns a local variable namedhook, which shadows the importedHookprotocol and makes the code harder to read (and can confuse type-checking/tooling). Rename the local variable to something specific likeconfirmation_hook_instance.
assert isinstance(deserialized_agent.tools[0], Tool)
assert deserialized_agent.tools[0].name == "addition_tool"
assert deserialized_agent.tool_concurrency_limit == agent.tool_concurrency_limit
assert deserialized_agent.tool_streaming_callback_passthrough == agent.tool_streaming_callback_passthrough
hook = deserialized_agent.hooks["before_tool"][0]
assert isinstance(hook, ConfirmationHook)
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
anakin87
approved these changes
Sep 10, 2026
This was referenced Sep 11, 2026
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.
Related Issues
Proposed Changes:
The agent hook and human-in-the-loop test modules are missing from the standard mypy target. This PR adds both modules and resolves their 19 existing type errors so CI checks them going forward.
The changes make test hooks satisfy the
Hookprotocol, verify concrete types after deserialization, and align confirmation mappings with the API. Method mocks use pytest'smonkeypatch. Three narrowly scoped, documented type ignores preserve tests that deliberately pass invalid inputs.How did you test it?
Validated locally on Windows:
hatch run test:types: passes for 504 files.hatch run test:unit test/components/agents/ test/hooks/: 670 passed, 1 skipped, 6 deselected.Notes for the reviewer
This PR changes tests and type-check coverage only. Please apply
ignore-for-release-notesif appropriate.This PR was generated with Codex.
Checklist
I have reviewed and performed all the local tests.