Skip to content

test: type-check agent hook and confirmation tests - #12681

Merged
anakin87 merged 1 commit into
deepset-ai:mainfrom
Koushik890:test/agent-contract-typing
Sep 10, 2026
Merged

anakin87 merged 1 commit into
deepset-ai:mainfrom
Koushik890:test/agent-contract-typing

Conversation

@Koushik890

Copy link
Copy Markdown
Contributor

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 Hook protocol, verify concrete types after deserialization, and align confirmation mappings with the API. Method mocks use pytest's monkeypatch. 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.
  • All applicable pre-commit hooks pass, including Ruff lint and formatting.

Notes for the reviewer

This PR changes tests and type-check coverage only. Please apply ignore-for-release-notes if appropriate.

This PR was generated with Codex.

Checklist

  • Existing tests updated and runtime expectations preserved.
  • Type annotations and intentional invalid-input exceptions documented.
  • Applicable pre-commit hooks passed.
  • Release-note exemption for tests-only changes.

I have reviewed and performed all the local tests.

@Koushik890
Koushik890 requested a review from a team as a code owner September 9, 2026 13:47
@Koushik890
Koushik890 requested review from anakin87 and a lite review from Copilot and removed request for a team September 9, 2026 13:47
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@Koushik890 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

🟢 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:types mypy 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.py and test/components/agents/test_agent_hitl.py to the mypy types script in pyproject.toml.
  • Update agent hook tests to satisfy the Hook protocol 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’s monkeypatch for 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

  • Hook is imported for typing, but this test later assigns a local variable named hook, which shadows the imported Hook protocol and makes the code harder to read (and can confuse type-checking/tooling). Rename the local variable to something specific like confirmation_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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

@anakin87
anakin87 merged commit 107565b into deepset-ai:main Sep 10, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants