Repository navigation
fix: keep turn spans parented correctly under event-ordering races - #147
enternal111 wants to merge 9 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
77deb2c to
ac7c647
Compare
|
@codex review |
|
@codex security review |
Codex Review Summary: ❌ FailedThis 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: ac7c64720e
ℹ️ 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.
ac7c647 to
d40b519
Compare
|
@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: d40b51903f
ℹ️ 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.
d40b519 to
b0b15c8
Compare
|
@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: b0b15c8b31
ℹ️ 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 |
|
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". |
Re-encode the truncated text so span attributes always carry valid JSON, and remove the remaining test comment.
b0b15c8 to
427da59
Compare
|
@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: 427da59bec
ℹ️ 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: c922bc83be
ℹ️ 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 |
|
@codex security review |
c9ffe09 to
99debb5
Compare
|
@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: 99debb50ae
ℹ️ 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 |
|
@codex review |
|
@codex security review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
99debb5 to
1781a6e
Compare
|
@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: 1781a6e84b
ℹ️ 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".
| .replace(/\b(?:for|with|query|search(?:ing)?\s+for)\s+.+$/i, " for [redacted]") | ||
| .slice(0, 128) |
There was a problem hiding this comment.
Omit error text that this regex cannot redact
When captureContent is false and a provider error echoes user text without one of these markers (for example, ProviderError: private prompt), this replacement does nothing and the following 128-character slice still exports the echoed text in span error status or attributes. Provider error formats are arbitrary, so omit the message or export only an allowlisted summary when capture is disabled.
Useful? React with 👍 / 👎.
|
@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. |
|
@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. |
|
@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: db85949721
ℹ️ 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".
| while (Date.now() < deadline) { | ||
| await new Promise((resolve) => setTimeout(resolve, ACTIVE_LLM_SETTLE_TICK_MS)) | ||
| await ctx.tracing.eventQueue | ||
| const current = ctx.tracing.activeLlm.get(event.sessionID) | ||
| if (!current || current.spanContext.spanId !== active.spanContext.spanId) { |
There was a problem hiding this comment.
Skip the settle delay for an already-current step span
When session.step.started for the same call has already been consumed before model.request, active is already that call's span and there is no queued transition to change its ID. This loop still sleeps in 15 ms increments until the 200 ms deadline, delaying every request in this ordering before it reaches the provider, including retries. Only wait when a previous-step transition is actually pending instead of polling an unchanged current span.
Useful? React with 👍 / 👎.
Which problem is this PR solving?
OpenCode may deliver
session.step.startedand fire themodel.requesthook before the queuedsession.execution.startedevent is consumed, and it can start the next step's request while the previous step's span is still finishing. Both event-ordering races produce broken traces:model.requesthook then propagates the still-active previous step's span context to the next request, so gateway spans are parented to a span that already ended (children outliving their parent).Short description of the changes
ensureRunSpan()creates the run span from themodel.requesthook and fromstep.startedwhenexecution.startedhas not been consumed yet, anchored to the enqueued prompt time so performance views keep the pre-request lead time;execution.startednow enriches an eagerly created run span instead of starting a duplicate.resolveRunContext()falls back to the parent session's run span so early subagent spans join the parent turn's trace.model.requesthook refuses to reuse an active entry whose span belongs to an already-ended or previous step (tracked viaisRecording()and afromStepmarker), and injects the run span's context into auxiliary requests so they join the turn instead of forking.finalizeSession()ends a dangling run span when an execution ends.How Has This Been Tested?
bun run typecheckbun run lintbun test(unit suite green; the one adjusted test now asserts auxiliary requests anchor to the run span rather than receiving no context at all)Depends on #146 (branch is stacked; only the last commit is new here).
Fixes #152