open-telemetry / open-telemetry/opentelemetry-python-genai

util-genai: ToolInvocation._apply_finish never calls the completion hook, so tool arguments/results bypass redaction hooks

Open Beginner friendly
#678 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39
Forks
63
Avg merge
1d 15h
Merged PRs (30d)
175

Description

Version: opentelemetry-util-genai 1.1b0 (_tool_invocation.py:120).

What happens. InferenceInvocation._apply_finish and WorkflowInvocation._apply_finish
call _call_completion_hook(...) before ending the span, so a CompletionHook registered through
the opentelemetry_genai_completion_hook entry point (the documented way to add redaction or
upload) sees inference and workflow content. ToolInvocation._apply_finish writes
gen_ai.tool.call.arguments and gen_ai.tool.call.result and ends the span without calling the
hook, so tool content bypasses every hook, including redaction.

Reproduce. Register a hook that records every call; run handler.tool("t") with
arguments={"token": "sk-..."}; the hook is never called and the attribute reaches the exporter.

Suggested fix. Call _call_completion_hook from ToolInvocation._apply_finish with the
arguments and result as inputs/outputs (or add a dedicated hook method for tools), consistently
with the other invocation types.

Downstream workaround (forgehawk SDK). forgehawk's own tool emitters (api.py, the LangChain subclass) redact
arguments and results directly before assignment (redaction.redact_tool_value); third-party
tool spans stay unredacted until this is fixed.


Found while building the forgehawk Python SDK (ZioSec) on top of opentelemetry-util-genai; happy to open a PR for the suggested fix if maintainers agree with the direction.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at _tool_invocation.py:120 and compare ToolInvocation._apply_finish with the corresponding finish methods on InferenceInvocation and WorkflowInvocation. Verify how _call_completion_hook receives inputs and outputs, then confirm that tool arguments and results pass through the hook before the span ends. Done means registered hooks observe both values, including for redaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.