fix(agent): restore legacy session tool recording and error routing

This commit is contained in:
Adam Weidman
2026-03-17 14:16:56 -04:00
parent ea19aeb14b
commit 1f727251eb
4 changed files with 47 additions and 6 deletions
@@ -16,6 +16,8 @@ import type { Scheduler } from '../scheduler/scheduler.js';
import type { Config } from '../config/config.js';
import type { ToolCallRequestInfo } from '../scheduler/types.js';
import { ToolErrorType } from '../tools/tool-error.js';
import { recordToolCallInteractions } from '../code_assist/telemetry.js';
import { debugLogger } from '../utils/debugLogger.js';
import {
translateEvent,
createTranslationState,
@@ -261,7 +263,16 @@ export class LegacyAgentSession implements AgentSession {
],
}
: {}),
...(response.data ? { data: response.data } : {}),
...(response.data || response.errorType
? {
data: {
...(response.data || {}),
...(response.errorType
? { errorType: response.errorType }
: {}),
},
}
: {}),
}),
]);
@@ -277,8 +288,12 @@ export class LegacyAgentSession implements AgentSession {
this._client
.getChat()
.recordCompletedToolCalls(currentModel, completedToolCalls);
} catch {
// Recording failures shouldn't break the loop
await recordToolCallInteractions(this._config, completedToolCalls);
} catch (error) {
debugLogger.error(
`Error recording completed tool call information: ${error}`,
);
}
// Check if a tool requested stop execution
+2
View File
@@ -74,6 +74,7 @@ export class MockAgentSession implements AgentSession {
const now = new Date().toISOString();
for (const eventData of events) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const event: AgentEvent = {
...eventData,
id: eventData.id ?? `e-${this._nextEventId++}`,
@@ -172,6 +173,7 @@ export class MockAgentSession implements AgentSession {
const normalizedResponse: AgentEvent[] = [];
for (const eventData of response) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const event: AgentEvent = {
...eventData,
id: eventData.id ?? `e-${this._nextEventId++}`,