Thread tool call context through policy
Refs #2132
Summary
- Adds structured
ToolCallContextto tool policy requests. - Threads session tool call metadata into policy checks before execution.
- Extends focused policy/session coverage for the context fields.
Codex PR Checklist
- [x] Issue URL: https://github.com/tinyhumansai/openhuman/issues/2132
- [x] Branch:
codex/oh-2132-tool-call-context - [x] Commit SHA:
2c87a4f7bdb975f6f9e3bce7bbaf4567b18b52df - [x] Files changed summary:
src/openhuman/agent/tool_policy.rsadds the context shape;src/openhuman/agent/harness/session/turn.rspopulates it for session tool calls;src/openhuman/agent/harness/session/turn_tests.rsasserts policy receives it. - [x] Validation commands run:
cargo fmt --manifest-path Cargo.toml --all --check;cargo test --manifest-path Cargo.toml tool_policy;node scripts/check-pr-checklist.mjs /tmp/pr-body-2132.md. - [x] Validation commands blocked:
pnpm pr:checklist /tmp/pr-body-2132.mdblocked withzsh:1: command not found: pnpm; used the same checklist checker vianode scripts/check-pr-checklist.mjs /tmp/pr-body-2132.md. - [x] Behavior change: Tool policies can now inspect structured tool call context before execution. No intended behavior change for tools or policies that ignore the new field.
- [x] Duplicate/stale PR note: No existing PR found for
vaddisrinivas:codex/oh-2132-tool-call-contextor issue2132before opening this draft PR.
Summary by CodeRabbit
-
Refactor
- Improved tool-invocation context tracking to include structured session, channel, agent, call and iteration metadata while keeping backward-compatible request fields.
- Policy requests now carry richer provenance and mirror legacy identifiers.
-
Tests
- Tightened tests to assert full context population and verify debug output redacts sensitive tool arguments and context fields.
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44a986a4-bd52-493e-820f-bbf932e09e9a
π₯ Commits
Reviewing files that changed from the base of the PR and between 9200fd2ac6745f51ecbad7fe7f203066f151c78a and 4bd36a3c75776d165c5b19b1f950ee69baa520b8.
π Files selected for processing (2)
src/openhuman/agent/harness/session/turn.rssrc/openhuman/agent/harness/session/turn_tests.rs
π Walkthrough
Walkthrough
A new ToolCallContext struct and ToolCallSource enum are introduced; ToolPolicyRequest gains a context: ToolCallContext and a new(...) constructor that mirrors key fields. Agent::execute_tool_call now builds ToolCallContext::session(...) and calls ToolPolicyRequest::new(...). Tests are updated to assert the populated request.context fields.
Changes
Tool call context refactoring
| Layer / File(s) | Summary |
|---|---|
Context types and ToolPolicyRequest contract src/openhuman/agent/tool_policy.rs |
Adds ToolCallContext with session(...), ToolCallSource enum, extends ToolPolicyRequest to include context and provides ToolPolicyRequest::new(...); tests updated to construct requests with the new context and assert mirror fields and context.call_id/context.source. |
Tool execution context integration and validation src/openhuman/agent/harness/session/turn.rs, src/openhuman/agent/harness/session/turn_tests.rs |
execute_tool_call imports ToolCallContext and constructs ToolCallContext::session(...), using ToolPolicyRequest::new(...) for policy checks. DenyCountingPolicy test assertions expanded to validate request.context fields (session_id, channel, agent_definition_id, call_id, iteration). |
Sequence Diagram(s)
sequenceDiagram
participant Agent as Agent::execute_tool_call
participant Policy as ToolPolicy
participant Executor as ToolExecutor
Agent->>Policy: ToolPolicyRequest::new(tool_name, args, ToolCallContext::session(...))
Policy->>Agent: allow / deny
Agent->>Executor: execute tool call (if allowed)
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~20 minutes
Possibly related issues
- tinyhumansai/openhuman#2132: Proposes adding and threading ToolCallContext and ToolPolicyRequest::new into policy/execution, matching this PR's changes.
Possibly related PRs
- tinyhumansai/openhuman#2137: Both PRs modify the tool-policy pre-execution path and introduce/consume structured ToolCallContext.
Suggested labels
working
π° I hop through code with a tidy knack, Context in paw, I stitch the track, Calls now carry their session song, Policies read it clear and strong, Debug hides secrets all day long π₯
π₯ Pre-merge checks | β 5
β Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'Thread tool call context through policy' accurately summarizes the main change: adding and threading ToolCallContext through tool policy requests across multiple files. |
| Docstring Coverage | β Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@vaddisrinivas unresolved review feedback from graycyrus β please address before we review.
Thanks for the nudge. I addressed the graycyrus review threads inline in 9200fd2 and marked the fixed conversations resolved. Re-review welcome.