Expose the current HarnessToolCall id to tool handlers (public accessor)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3
- Forks
- 1
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 20
Description
Component
hyperforge.harness_sdk (AgentHarness._execute_tool_call, HarnessTool.execute)
Summary
When the Harness executes a tool call, the call's id is emitted in the TOOL_REQUESTED event and then the handler is invoked with only the harness and the validated input (HarnessTool.execute → await self.handler(harness, value)). The handler has no public way to learn which tool call it is executing:
AgentHarness._execute_tool_callemitsTOOL_REQUESTEDwithcall.id, then callstool.execute(self, call.arguments).harness.turn_idis a public property, but there is no public accessor for the activeHarnessToolCall(the onlycall-related attributes onAgentHarnessare the private_execute_tool_call/_execute_tool_callsmethods).
Impact
Handlers that fan out nested work and emit their own lifecycle events cannot correlate those events with the parent tool call. Concrete example from an embedding application: a scoped "Code Mode" tool that runs restricted Python in a remote sandbox and exposes a fixed set of nested capabilities must emit TOOL_REQUESTED/TOOL_COMPLETED/TOOL_FAILED for each nested capability call; without the outer call id, those events cannot be parented to the harness's own tool-call event, and downstream consumers cannot reconstruct the hierarchy. The only workaround today is reading private harness state, which public-API consumers must not do.
Verified on hyperforge==1.0.0.post310.
Proposal (non-breaking)
Expose a read-only property, set and cleared around execution:
@property
def current_tool_call(self) -> HarnessToolCall | None:
return self._current_tool_call
# in _execute_tool_call:
self._current_tool_call = call
try:
...
finally:
self._current_tool_call = None
An alternative is passing a context object to handlers, but that changes the handler signature and belongs to a major-version design discussion; the property unblocks event correlation now without touching the handler contract.
Acceptance criteria
- During a tool execution,
harness.current_tool_call.idequals thecall.idemitted in the correspondingTOOL_REQUESTEDevent. - Outside of an execution (including after exceptions/cancellation),
current_tool_callisNone.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in hyperforge.harness_sdk at AgentHarness._execute_tool_call and HarnessTool.execute, tracing when the TOOL_REQUESTED event is emitted and when the handler runs. Add the public current_tool_call behavior described in the proposal, then verify the accessor exposes the matching call id during execution and is None after normal completion, exceptions, and cancellation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100