fix(runs): encode agent prompts and action input with sorted keys (#2083)
This commit is contained in:
4 files changed
+6
-4
No files matched your search
@@ -503,7 +503,8 @@ func followThrough(rc *Context, judge Judge, decls []connectors.Declaration, inp
|
||||
if len(missed) == 0 {
|
||||
return res, nil
|
||||
}
|
||||
prompt, err := json.Marshal(map[string]any{"event": input, "findings": res.Answer, "described_but_not_called": missed})
|
||||
// The prompt is part of the journaled request digest, so its key order must be the same on replay.
|
||||
prompt, err := json.Marshal(map[string]any{"event": input, "findings": res.Answer, "described_but_not_called": missed}, json.Deterministic(true))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ func recordCause(rc *Context, mem Memory, input jsontext.Value, res AgentResult,
|
||||
if !res.Completed {
|
||||
return nil
|
||||
}
|
||||
prompt, err := json.Marshal(map[string]any{"event": input, "findings": res.Answer})
|
||||
// The prompt is part of the journaled request digest, so its key order must be the same on replay.
|
||||
prompt, err := json.Marshal(map[string]any{"event": input, "findings": res.Answer}, json.Deterministic(true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ func stringify(value any) string {
|
||||
case string:
|
||||
return v
|
||||
default:
|
||||
encoded, err := json.Marshal(v)
|
||||
encoded, err := json.Marshal(v, json.Deterministic(true))
|
||||
if err != nil {
|
||||
return fmt.Sprint(v)
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func runAction(d Deps, rc *Context, p *progress, name string, s actionSettings)
|
||||
if input == nil {
|
||||
input = map[string]any{}
|
||||
}
|
||||
in, err := json.Marshal(input)
|
||||
in, err := json.Marshal(input, json.Deterministic(true))
|
||||
if err != nil {
|
||||
return StepResult{}, fmt.Errorf("step %q: encode input: %w", name, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user