Skip to content

fix: correlate LiteLLM prompts with native agent turns - #5067

Open
danielkov wants to merge 5 commits into
mainfrom
fix/opencode-litellm-prompt-correlation
Open

fix: correlate LiteLLM prompts with native agent turns#5067
danielkov wants to merge 5 commits into
mainfrom
fix/opencode-litellm-prompt-correlation

Conversation

@danielkov

@danielkov danielkov commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • correlate LiteLLM and native hook prompts using stable provider turn identities for OpenCode and Codex
  • atomically promote LiteLLM rows to the authoritative native source regardless of arrival order
  • suppress LiteLLM transcript prompts for Claude and Cursor sessions once their native hook stream is known
  • forward agent identity headers in generated LiteLLM config and republish the OpenCode observability plugin
  • remain compatible with the currently pinned hooks binary by normalizing legacy Codex turn IDs and extracting OpenCode message IDs from raw events

Rollout Note

Existing customer-managed LiteLLM instances must apply the updated generated config so the new turn identity headers are forwarded to the Gram guardrail. The control plane cannot mutate external LiteLLM configuration.

@danielkov
danielkov requested a review from a team as a code owner August 7, 2026 17:19
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6e345a5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread server/internal/hooks/ingest_hooks.go Outdated
Comment thread server/internal/hooks/ingest_hooks.go Outdated
@danielkov
danielkov requested a review from a team as a code owner August 7, 2026 19:05
@danielkov danielkov changed the title fix: coalesce LiteLLM prompts with OpenCode hooks fix: correlate LiteLLM prompts with native agent turns Aug 7, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 20 files (changes from recent commits).

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread server/internal/chat/message_store.go
Comment thread server/internal/litellm/impl.go Outdated
Comment thread server/internal/hooks/ingest_hooks.go Outdated
Comment thread server/internal/hooks/ingest_hooks.go Outdated
Comment thread server/internal/litellm/impl.go
Comment thread hooks/relay/envelope.go
@danielkov danielkov added the review:bypass Merge without human review approval. Required status checks still apply. label Aug 7, 2026
gram-bot[bot]
gram-bot Bot previously approved these changes Aug 7, 2026

@gram-bot gram-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: review:bypass label applied by @danielkov. Required status checks still gate this merge.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread server/internal/chat/queries.sql Outdated
Comment thread server/internal/hooks/ingest_hooks.go Outdated
@danielkov danielkov removed the review:bypass Merge without human review approval. Required status checks still apply. label Aug 7, 2026
@gram-bot
gram-bot Bot dismissed their stale review August 7, 2026 21:00

review:bypass label removed by @danielkov.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread server/internal/hooks/session_capture.go Outdated
Comment thread server/internal/hooks/session_capture.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant