Skip to content

feat(core): tag model calls with tfg.thread_id - #1392

Open
hary73 wants to merge 1 commit into
mainfrom
haryahuja/age-2837-add-tfgthread_id-to-metadata-in-model
Open

hary73 wants to merge 1 commit into
mainfrom
haryahuja/age-2837-add-tfgthread_id-to-metadata-in-model

Conversation

@hary73

@hary73 hary73 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Gateway traces carry the session, turn and agent IDs in x-tfy-metadata, but nothing identifies which thread made a call, so a subagent's calls can't be told apart from the root's. This tags every model call with tfg.thread_id. It's the groundwork for subagent model routing (PR #1390), where a routing decision is joined to the calls the subagent made.

Linear: AGE-2837

Changes

  • AgentThread passes { 'tfg.thread_id': threadId } as per-call metadata on its model call. buildOutboundRequestHeaders already folds per-call metadata into x-tfy-metadata for TrueFoundry providers and ignores it for others.
  • Context compaction tags its summarisation call with tfg.thread_id too, from the execution context it already receives, next to tfg.compaction.
  • Subagents can't spawn subagents and the root thread is always main, so a separate parent thread ID would add nothing.

How was this tested?

  • No new tests: folding per-call metadata into x-tfy-metadata is already covered by buildOutboundRequestHeaders.test.ts.
  • trueforge-core: typecheck and the full test suite pass. ESLint and Prettier are clean on the changed files.

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally (only trueforge-core typecheck and tests, plus lint and format on the changed files, were run)
  • Tests added/updated where it makes sense (none needed)
  • No hand-edits to generated code
  • Docs / .env.example updated if configuration or behavior changed (n/a)

Made with Cursor


Note

Low Risk
Small additive metadata on existing LLM call paths; header folding is already tested and behavior is unchanged for non–TrueFoundry providers.

Reviewed by Cursor Bugbot for commit d79dd9a. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d79dd9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-core Patch
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

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

@hary73
hary73 force-pushed the haryahuja/age-2837-add-tfgthread_id-to-metadata-in-model branch 2 times, most recently from bfe6224 to cfb7154 Compare November 16, 2026 07:47
Co-authored-by: Cursor <cursoragent@cursor.com>
@hary73
hary73 force-pushed the haryahuja/age-2837-add-tfgthread_id-to-metadata-in-model branch from cfb7154 to d79dd9a Compare November 16, 2026 07:48
@hary73
hary73 marked this pull request as ready for review November 16, 2026 07:49
@veria-ai

veria-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

This branch has not been deployed

No deployments
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.

2 participants