Repository navigation
fix: gate span content capture behind OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT - #146
enternal111 wants to merge 7 commits into
Conversation
…URE_MESSAGE_CONTENT Span attributes that embed user or model content (input.value, output.value, llm.input_messages, llm.output_messages, session run span prompt text, and tool parameters/inputs/outputs) are now emitted only when capture is explicitly enabled, either via the new captureContent plugin option or the standard OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable (true/1). The default is privacy-first: content is not captured, matching the OpenTelemetry GenAI semantic-conventions guidance for message content. Fixes DEVtheOPS#144
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53bb29231b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…option Follow the repository convention that plugin settings use the OPENCODE_ namespace. Document captureContent in the README environment variable and plugin option tables, and update the privacy note to cover span content.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c2d2608e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Cap the JSON.stringify of tool input to 64 KB, matching the bound the step handler already applies to streamed text.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b116d73971
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b116d73971
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Re-encode the truncated text so span attributes always carry valid JSON, and remove the remaining test comment.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
@codex security review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57fffba91b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| span.setStatus({ code: SpanStatusCode.ERROR, message }) | ||
| span.setAttribute("error", message) | ||
| span.setStatus({ code: SpanStatusCode.ERROR, message: ctx.captureContent ? message : redactErrorMessage(message) }) | ||
| span.setAttribute("error", ctx.captureContent ? message : redactErrorMessage(message)) |
There was a problem hiding this comment.
Redact errors before emitting failure logs
When captureContent is off (the default) and a failed session or tool error echoes a prompt or query, this redacts only the span fields: handleExecutionEnded still emits the raw message in session.error, and finishTool still emits the raw error in tool_result. Since OTLP logs are enabled by default, those failures still export user content despite the privacy mode; redact those log attributes too.
Useful? React with 👍 / 👎.
| .replace(/\b(?:for|with|query|search(?:ing)?\s+for)\s+.+$/i, " for [redacted]") | ||
| .slice(0, 128) |
There was a problem hiding this comment.
Fail closed when an error does not match the redactor
An upstream error may echo input as prompt: <text> or in another format without these trigger words; the regex then does not match, and the fallback only truncates to 128 characters, so a short prompt is still written into status/error attributes and the api_error log with content capture disabled. Since StructuredError.message is arbitrary text, retain only a safe error type/status on non-matches instead of forwarding the message.
Useful? React with 👍 / 👎.
| "agent.type": totals?.agentType ?? "primary", | ||
| "session.is_subagent": isSubagent, | ||
| ...(promptText | ||
| ...(promptText && ctx.captureContent |
There was a problem hiding this comment.
Bound the prompt on the session span
When content capture is enabled for a prompt longer than 64,000 characters, handleExecutionStarted puts the entire pendingPrompt.text into input.value and llm.input_messages; unlike handleStepStarted, this session-span path never slices it. This can still create an oversized span despite the new content limit, so cap the root prompt before attaching it.
AGENTS.md reference: AGENTS.md:L61-L61
Useful? React with 👍 / 👎.
Which problem is this PR solving?
Fixes #144. Every LLM, session, and tool span embeds the full user/model content (
input.value,output.value,llm.input_messages,llm.output_messages, run-span prompt text,tool.parametersand tool inputs/outputs), so traces sent to a hosted OTLP backend effectively contain the entire conversation. Additionally, error messages (tool.error, spanstatusMessage,api_errorlog attributes) can echo user input (e.g. a websearch query repeated in the failure text), and captured content is unbounded.Short description of the changes
captureContentplugin option, plus theOPENCODE_CAPTURE_CONTENTenvironment variable, following the OpenTelemetry GenAI semantic-conventions guidance for message-content capture. The default is privacy-first: content is not captured.How Has This Been Tested?
bun run typecheckbun run lintbun test(unit suite; content-asserting tests opt in through the env var)