mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
Session persistence moves from internal/runtime/agent to internal/state/sessionstore: the Session type, its checkpoint and event log, listing sidecars, branches, leases, recovery copies, migration, and the compaction and subagent records saved beside a transcript. The agent keeps the loop and imports the store; history, historycatalog, migration, guardian, instanceid and sessiontool now reach the store instead of the agent, which drops layer-order from 26 to 18. Tests that exercise only store internals moved with it; the rest stay in agent and qualify the moved names. DigestSessionMessages and CompactionStateSchemaV1 are exported for the agent tests that build legacy fixtures. Baseline: carried with -allow-widen. The moved files bring their essay, file-size, complexity and orphan debt unchanged under new paths, and boot.go, acp/service.go, serve/serve.go, agent/task.go and control/controller.go each gain the one import line the split costs.
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"reasonix/internal/state/sessionstore"
|
|
"testing"
|
|
|
|
"reasonix/internal/contract/event"
|
|
"reasonix/internal/contract/provider"
|
|
"reasonix/internal/contract/tool"
|
|
)
|
|
|
|
// TestEarlyToolDispatch proves a ChunkToolCallStart surfaces a ToolDispatch
|
|
// immediately (Partial, name only) so the card shows while the arguments are
|
|
// still streaming, and that a second, full dispatch (with args) follows once the
|
|
// call completes — the fix for "the edit_file card only appears after everything
|
|
// is written".
|
|
func TestEarlyToolDispatch(t *testing.T) {
|
|
prov := &mockProvider{name: "p", chunks: []provider.Chunk{
|
|
{Type: provider.ChunkToolCallStart, ToolCall: &provider.ToolCall{ID: "c1", Name: "read_file"}},
|
|
{Type: provider.ChunkToolCall, ToolCall: &provider.ToolCall{ID: "c1", Name: "read_file", Arguments: `{"path":"/x"}`}},
|
|
{Type: provider.ChunkDone},
|
|
}}
|
|
reg := tool.NewRegistry()
|
|
reg.Add(fakeTool{name: "read_file", readOnly: true})
|
|
|
|
var got []event.Event
|
|
sink := event.FuncSink(func(e event.Event) { got = append(got, e) })
|
|
a := New(prov, reg, sessionstore.NewSession(""), Options{MaxSteps: 1}, sink)
|
|
_ = a.Run(context.Background(), "go") // errors at the 1-step cap; we only want the events
|
|
|
|
var partial, full int
|
|
for _, e := range got {
|
|
if e.Kind != event.ToolDispatch {
|
|
continue
|
|
}
|
|
if e.Tool.Partial {
|
|
partial++
|
|
if e.Tool.Name != "read_file" {
|
|
t.Errorf("partial dispatch name = %q, want read_file", e.Tool.Name)
|
|
}
|
|
} else {
|
|
full++
|
|
if e.Tool.Args == "" {
|
|
t.Errorf("full dispatch should carry args, got none")
|
|
}
|
|
}
|
|
}
|
|
if partial != 2 {
|
|
t.Errorf("want 2 partial (early) dispatches (original + grace-round replay), got %d", partial)
|
|
}
|
|
if full != 1 {
|
|
t.Errorf("want 1 full dispatch, got %d", full)
|
|
}
|
|
}
|