Fix goal recovery
This commit is contained in:
parent
3846556035
commit
996f586bc1
1 changed files with 783 additions and 145 deletions
|
|
@ -21,6 +21,8 @@ type fakeDaemon struct {
|
|||
before func(message)
|
||||
lostReply bool
|
||||
setError *rpcError
|
||||
usage *bool
|
||||
usageErr *rpcError
|
||||
}
|
||||
|
||||
func newFake(t *testing.T, s *store) *fakeDaemon {
|
||||
|
|
@ -44,7 +46,7 @@ func newFake(t *testing.T, s *store) *fakeDaemon {
|
|||
f := &fakeDaemon{path: path, t: t, goal: testGoal(active), turn: testTurn("inProgress"), status: "systemError"}
|
||||
c := &connection{frames: make(chan frame, 32)}
|
||||
op := &operator{
|
||||
opts: options{base: time.Second, cap: time.Minute}, store: s, conn: c,
|
||||
opts: options{base: time.Second, cap: time.Minute, poll: time.Second}, store: s, conn: c,
|
||||
log: io.Discard, attached: make(map[string]bool), jitter: func(d time.Duration) time.Duration { return d },
|
||||
}
|
||||
f.op = op
|
||||
|
|
@ -74,6 +76,12 @@ func (f *fakeDaemon) write(data []byte) error {
|
|||
}
|
||||
var result any
|
||||
switch m.Method {
|
||||
case "account/rateLimits/read":
|
||||
if f.usageErr != nil {
|
||||
f.enqueue(message{ID: m.ID, Error: f.usageErr})
|
||||
return nil
|
||||
}
|
||||
result = usageResult{Allowed: f.usage}
|
||||
case "thread/loaded/list":
|
||||
result = loadedResult{Data: []string{"thread-1"}}
|
||||
case "thread/goal/get":
|
||||
|
|
@ -345,7 +353,11 @@ func TestNoCompetingRetry(t *testing.T) {
|
|||
}
|
||||
|
||||
func intentLine(status goalStatus) []byte {
|
||||
body := "<codex_internal_context source=\"user_goal\">\nUser set goal status: " + string(mustJSON(status)) + ".\n</codex_internal_context>"
|
||||
instruction := "User set goal status: " + string(mustJSON(status)) + "."
|
||||
if status == "cleared" {
|
||||
instruction = "User cleared the goal."
|
||||
}
|
||||
body := "<codex_internal_context source=\"user_goal\">\n" + instruction + "\n</codex_internal_context>"
|
||||
return append(mustJSON(map[string]any{"type": "response_item", "payload": map[string]any{
|
||||
"type": "message", "role": "user", "content": []any{map[string]string{"type": "input_text", "text": body}},
|
||||
"internal_chat_message_metadata_passthrough": map[string]any{"content_item_kinds": []string{"user.goal"}},
|
||||
|
|
@ -378,3 +390,9 @@ func (f *fakeDaemon) human(g *goal) {
|
|||
appendIntent(f.t, f.path, intentLine(g.Status))
|
||||
f.notify("thread/goal/updated", map[string]any{"threadId": "thread-1", "goal": g})
|
||||
}
|
||||
|
||||
func (f *fakeDaemon) agent(g *goal) {
|
||||
appendIntent(f.t, f.path, agentCall("block-1", "update_goal", "functions", g.Status))
|
||||
appendIntent(f.t, f.path, agentReply("block-1", string(mustJSON(goalResult{Goal: g}))))
|
||||
f.notify("thread/goal/updated", params{ThreadID: "thread-1", Goal: g})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue