TestAdvisorChainMode_SnapshotKeepsFullHistory exercises the advisor runtime together with chain mode and asserts the snapshot captured for the nested advisor call retains the full pre-chain prompt. Chain mode otherwise strips assistant and tool turns from the prompt the outer loop sees, so a regress
(t *testing.T)
| 10316 | // nested call. The advisor would then only see the trailing user |
| 10317 | // message, losing the context the outer model had been building on. |
| 10318 | func TestAdvisorChainMode_SnapshotKeepsFullHistory(t *testing.T) { |
| 10319 | t.Parallel() |
| 10320 | // TODO(CODAGT-353): Re-enable this test after the chatd notification flow |
| 10321 | // refactor gives workers enough causal information to distinguish stale |
| 10322 | // control NOTIFY messages from real interrupts. The current design reuses |
| 10323 | // the same status notification shape for wake-only and interrupt intents, |
| 10324 | // so a stale NOTIFY can cancel a new processChat run. |
| 10325 | t.Skip("skipped until chatd notification flow refactor handles stale control notifications") |
| 10326 | |
| 10327 | db, ps := dbtestutil.NewDB(t) |
| 10328 | ctx := testutil.Context(t, testutil.WaitLong) |
| 10329 | |
| 10330 | const ( |
| 10331 | turn1User = "help me refactor this module" |
| 10332 | turn1Reply = "happy to help, tell me more" |
| 10333 | turn1RespID = "resp_turn1_advisor_chain" |
| 10334 | turn2User = "follow up question" |
| 10335 | advisorReply = "narrow the scope to one module" |
| 10336 | finalReply = "acknowledged" |
| 10337 | ) |
| 10338 | |
| 10339 | var ( |
| 10340 | requestsMu sync.Mutex |
| 10341 | requests []recordedOpenAIRequest |
| 10342 | advisorRequestRaw []byte |
| 10343 | advisorCallSeen atomic.Bool |
| 10344 | ) |
| 10345 | |
| 10346 | openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse { |
| 10347 | if !req.Stream { |
| 10348 | return chattest.OpenAINonStreamingResponse("title") |
| 10349 | } |
| 10350 | |
| 10351 | // The advisor's nested call runs with no tools (MaxSteps=1, |
| 10352 | // empty tool set). Parent calls always carry the chat's tool |
| 10353 | // set, which includes the advisor tool. |
| 10354 | isAdvisorNested := len(req.Tools) == 0 |
| 10355 | |
| 10356 | requestsMu.Lock() |
| 10357 | requests = append(requests, recordOpenAIRequest(req)) |
| 10358 | if isAdvisorNested { |
| 10359 | advisorRequestRaw = append([]byte(nil), req.RawBody...) |
| 10360 | advisorCallSeen.Store(true) |
| 10361 | } |
| 10362 | requestsMu.Unlock() |
| 10363 | |
| 10364 | if isAdvisorNested { |
| 10365 | return chattest.OpenAIStreamingResponse( |
| 10366 | chattest.OpenAITextChunks(advisorReply)..., |
| 10367 | ) |
| 10368 | } |
| 10369 | |
| 10370 | // Turn 1 parent request: no previous_response_id yet, so chain |
| 10371 | // mode cannot activate. Respond with a plain text reply and |
| 10372 | // tag the stored response id so turn 2 can chain off it. |
| 10373 | if req.PreviousResponseID == nil { |
| 10374 | resp := chattest.OpenAIStreamingResponse( |
| 10375 | chattest.OpenAITextChunks(turn1Reply)..., |
nothing calls this directly
no test coverage detected