@@ -417,6 +417,48 @@ describe("agentCommand", () => {
|
417 | 417 | }); |
418 | 418 | }); |
419 | 419 | |
| 420 | +it("gap-fills Telegram-visible embedded replies without a runner trace", async () => { |
| 421 | +await withTempHome(async (home) => { |
| 422 | +const store = path.join(home, "sessions.json"); |
| 423 | +mockConfig(home, store); |
| 424 | +const sendMessageTelegram = vi.fn(async () => undefined); |
| 425 | +const base = createDefaultAgentResult({ payloads: [{ text: "assistant-visible" }] }); |
| 426 | +vi.mocked(runEmbeddedPiAgent).mockResolvedValueOnce({ |
| 427 | + ...base, |
| 428 | +meta: { |
| 429 | + ...base.meta, |
| 430 | +finalAssistantVisibleText: "assistant-visible", |
| 431 | +}, |
| 432 | +}); |
| 433 | + |
| 434 | +await agentCommandFromIngress( |
| 435 | +{ |
| 436 | +message: "call a tool then answer", |
| 437 | +agentId: "main", |
| 438 | +to: "+1222", |
| 439 | +channel: "telegram", |
| 440 | +messageChannel: "telegram", |
| 441 | +deliver: true, |
| 442 | +senderIsOwner: false, |
| 443 | +allowModelOverride: false, |
| 444 | +}, |
| 445 | +runtime, |
| 446 | +{ sendMessageTelegram }, |
| 447 | +); |
| 448 | + |
| 449 | +expect(sendMessageTelegram).toHaveBeenCalledWith( |
| 450 | +"+1222", |
| 451 | +"assistant-visible", |
| 452 | +expect.objectContaining({ verbose: false }), |
| 453 | +); |
| 454 | +expect(vi.mocked(attemptExecutionRuntime.persistCliTurnTranscript)).toHaveBeenCalledTimes(1); |
| 455 | +const persistArgs = vi.mocked(attemptExecutionRuntime.persistCliTurnTranscript).mock |
| 456 | +.calls[0]?.[0]; |
| 457 | +expect(persistArgs?.embeddedAssistantGapFill).toBe(true); |
| 458 | +expect(persistArgs?.body).toBe("call a tool then answer"); |
| 459 | +}); |
| 460 | +}); |
| 461 | + |
420 | 462 | it("passes configured fast mode to embedded runs", async () => { |
421 | 463 | await withTempHome(async (home) => { |
422 | 464 | const store = path.join(home, "sessions.json"); |
|