(messages: MsgLike[])
| 71 | } |
| 72 | |
| 73 | export function gatherSessionEvidence(messages: MsgLike[]): SessionEvidence { |
| 74 | let didSuccessfulEdit = false; |
| 75 | let didRunTests = false; |
| 76 | let didRunShell = false; |
| 77 | |
| 78 | for (const m of messages) { |
| 79 | // Attempted tool calls (assistant side) — read shell command args for test runners. |
| 80 | if (m.role === 'assistant' && Array.isArray(m.tool_calls)) { |
| 81 | for (const tc of m.tool_calls) { |
| 82 | const name = tc.function?.name ?? ''; |
| 83 | const args = tc.function?.arguments ?? ''; |
| 84 | if (name === 'shell' || name === 'auto_fix' || name === 'code_run') { |
| 85 | didRunShell = true; |
| 86 | if (TEST_RUNNER_RE.test(args)) didRunTests = true; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | // Tool results (tool side) — confirm success (non-error) and scan for test output. |
| 91 | if (m.role === 'tool') { |
| 92 | const name = m.name ?? ''; |
| 93 | const content = typeof m.content === 'string' ? m.content : ''; |
| 94 | const isError = ERROR_PREFIX_RE.test(content); |
| 95 | if (EDIT_TOOLS.has(name) && !isError) didSuccessfulEdit = true; |
| 96 | if (name === 'shell' || name === 'auto_fix' || name === 'code_run') { |
| 97 | didRunShell = true; |
| 98 | if (TEST_RUNNER_RE.test(content) || TEST_RESULT_RE.test(content)) didRunTests = true; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | return { didSuccessfulEdit, didRunTests, didRunShell }; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Returns a corrective observation when the final message makes a claim the session |
no test coverage detected