MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / countTrailingToolErrors

Function countTrailingToolErrors

src/agent/thinking-control.ts:65–74  ·  view source on GitHub ↗
(messages: Message[])

Source from the content-addressed store, hash-verified

63export function modelSupportsSoftSwitch(modelId: string): boolean {
64 return /qwen-?3/i.test(modelId);
65}
66
67/** Count error results in the contiguous block of tool messages at the tail.
68 * QodeX tools conventionally prefix failures with "[ERROR]". Pure. */
69export function countTrailingToolErrors(messages: Message[]): number {
70 let n = 0;
71 for (let i = messages.length - 1; i >= 0; i--) {
72 const m = messages[i]!;
73 if (m.role !== 'tool') break;
74 const c = typeof m.content === 'string' ? m.content : '';
75 if (/^\s*\[ERROR\]/i.test(c) || /^Error:/m.test(c.slice(0, 200))) n++;
76 }
77 return n;

Callers 2

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected