Why: Project messages, retrieved evidence, tool results, and final replies must not affect model work or reach users before the domain risk decision is complete. Evidence: RED tests proved the runner, final reply, and message deltas advanced before the gate; focused tests, go test -p 1 ./..., go build ./..., and isolated PostgreSQL runtime tests now pass. Impact: Wire the optional RDM observer into project run start, retrieval, tool-result, HITL clarification, and final reply buffering; hosts without the optional provider keep existing behavior. Refs: TT-N03, TT-R01; approved work-observation design and stage-five plan
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package runmgr
|
|
|
|
import (
|
|
"testing"
|
|
|
|
core "agent-system-core"
|
|
)
|
|
|
|
func TestProjectToolResultRecordsActualOutputBeforeModelUse(t *testing.T) {
|
|
rc, st := newExecEnv(t)
|
|
run := core.Run{ConversationID: rc.run.ConversationID, ProjectID: rc.run.ProjectID, Owner: rc.run.Owner,
|
|
Kind: core.RunConversation, Status: core.RunRunning, Phase: core.PhaseThinking}
|
|
if err := st.CreateRun(&run); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
rc.run = run
|
|
enableProjectGateForTest(rc.mgr)
|
|
result := rc.ExecuteTool(core.ToolCallRequest{CallID: "tool-1", Name: "time_now", Arguments: []byte(`{}`)})
|
|
if result.Status != "ok" || result.Output == "" {
|
|
t.Fatalf("tool did not return its actual output: %+v", result)
|
|
}
|
|
rows, err := st.PendingProjectWorkObservations(10)
|
|
if err != nil || len(rows) != 1 || rows[0].SourceKind != "tool-result" || rows[0].SourceID != "tool-1" || rows[0].Text != result.Output || rows[0].Metadata["toolName"] != "time_now" {
|
|
t.Fatalf("actual tool output was not captured before return: %+v %v", rows, err)
|
|
}
|
|
missingID := rc.ExecuteTool(core.ToolCallRequest{Name: "time_now", Arguments: []byte(`{}`)})
|
|
if missingID.Status != "error" {
|
|
t.Fatalf("tool output without stable call ID reached model: %+v", missingID)
|
|
}
|
|
}
|