TestToolTargetKey pins the identity the repeated-failure nudge keys on: file tools key on tool+path, bash on tool + the trimmed first command line, else the bare tool name. Deliberately NOT the full args: a cosmetic retry change (regenerated body, reworded tail) must not reset the streak.
(t *testing.T)
| 1725 | // counts what was generated up to the interrupt and the session total doesn't |
| 1726 | // drop backward. (On a clean finish the estimate is already 0, so this is a no-op.) |
| 1727 | func TestFinalizeFoldsInFlightEstimate(t *testing.T) { |
| 1728 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 1729 | m.turnStart = time.Now() |
| 1730 | m.turnTokens = 40 // one completed round |
| 1731 | m.streamingEstimate = 60 // an in-flight round cancelled before EventDone |
| 1732 | m.sessionTokens = 200 |
| 1733 | m.finalizeTurn(outcomeStopped) |
| 1734 | if m.lastTokens != 100 { |
| 1735 | t.Fatalf("frozen tokens should fold the in-flight estimate (40+60), got %d", m.lastTokens) |
| 1736 | } |
| 1737 | if m.sessionTokens != 260 { |
| 1738 | t.Fatalf("session total should absorb the in-flight estimate (200+60), got %d", m.sessionTokens) |
| 1739 | } |
| 1740 | if m.streamingEstimate != 0 { |
| 1741 | t.Fatalf("finalizeTurn should consume the estimate, got %d", m.streamingEstimate) |
| 1742 | } |
| 1743 | if m.lastOutcome != outcomeStopped { |
| 1744 | t.Fatalf("abort should freeze outcomeStopped, got %v", m.lastOutcome) |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | // TestToolTargetKey pins the identity the repeated-failure nudge keys on: file |
| 1749 | // tools key on tool+path, bash on tool + the trimmed first command line, else |
| 1750 | // the bare tool name. Deliberately NOT the full args: a cosmetic retry change |
| 1751 | // (regenerated body, reworded tail) must not reset the streak. |
| 1752 | func TestToolTargetKey(t *testing.T) { |
| 1753 | cases := []struct { |
| 1754 | name string |
| 1755 | call chmctx.ToolCall |
| 1756 | want string |
| 1757 | }{ |
| 1758 | {"write_file keys on path", chmctx.ToolCall{ |
| 1759 | Name: tools.WriteFileName, Arguments: map[string]any{"path": "/a/b.go", "content": "anything"}, |
| 1760 | }, tools.WriteFileName + "|/a/b.go"}, |
nothing calls this directly
no test coverage detected