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 {
|
if len(missed) == 0 {
|
||||||
return res, nil
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ func recordCause(rc *Context, mem Memory, input jsontext.Value, res AgentResult,
|
|||||||
if !res.Completed {
|
if !res.Completed {
|
||||||
return nil
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ func stringify(value any) string {
|
|||||||
case string:
|
case string:
|
||||||
return v
|
return v
|
||||||
default:
|
default:
|
||||||
encoded, err := json.Marshal(v)
|
encoded, err := json.Marshal(v, json.Deterministic(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Sprint(v)
|
return fmt.Sprint(v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func runAction(d Deps, rc *Context, p *progress, name string, s actionSettings)
|
|||||||
if input == nil {
|
if input == nil {
|
||||||
input = map[string]any{}
|
input = map[string]any{}
|
||||||
}
|
}
|
||||||
in, err := json.Marshal(input)
|
in, err := json.Marshal(input, json.Deterministic(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return StepResult{}, fmt.Errorf("step %q: encode input: %w", name, err)
|
return StepResult{}, fmt.Errorf("step %q: encode input: %w", name, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user