Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/model-call-thread-id-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@truefoundry/trueforge-core': patch
---

Tag every model call with `tfg.thread_id` in TrueFoundry gateway metadata, including context-compaction calls, so gateway traces can be grouped by thread.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class ContextCompaction implements PreLLMAgentContextProcessor {
let response: Awaited<ReturnType<ILLM['createNonStream']>>;
try {
response = await this.modelClient.createNonStream(body, {
metadata: { 'tfg.compaction': 'true' },
metadata: { 'tfg.thread_id': execution.threadId, 'tfg.compaction': 'true' },
});
} catch (error) {
getOperationMetrics()?.recordHarnessLimit({ limit: 'context_compaction_error' });
Expand Down
2 changes: 1 addition & 1 deletion packages/trueforge-core/src/core/runtime/AgentThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ export class AgentThread {
const requestBody = this.transformToLLMRequest(tools);
// Duration includes the provider stream and each delta's drain. appendToContext stays outside.
const requestStartedMs = performance.now();
const llmStream = this.definition.modelClient.create(requestBody);
const llmStream = this.definition.modelClient.create(requestBody, { metadata: { 'tfg.thread_id': this.threadId } });

// We start the delta stream with a model message event.
// `model` FQN is known from the bound client before any chunk arrives.
Expand Down
Loading