Model stages: outcome-first output shape and one in-session outcome repair
The prompt now says output.md must start with # outcome and the outcome word alone on the next line, then # handoff, then detail. Runs 241/243 followed the old "start with # handoff" wording and dropped the outcome. When a completed turn lacks a valid outcome, the OpenCode/agent and Pi clients send one short follow-up in the same session asking only for the outcome line. An outcome-only reply goes at the top of the original report; a still-invalid reply fails with the same validation error as before. The follow-up's tokens accrue to the session usage. No outcome is inferred. Missing tools/evidence now name blocked when declared, else error. The parser tolerates a trailing period on the outcome word.
This commit is contained in:
+24
-1
@@ -329,8 +329,31 @@ func (c *PiClient) Generate(ctx context.Context, config ModelConfig, prompt stri
|
||||
if _, err = c.rpc(ctx, "prompt", map[string]any{"message": prompt}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if text, err = c.settleTurn(ctx); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// One outcome repair follow-up in the same Pi session; get_session_stats
|
||||
// reports session totals, so its tokens are counted by the re-read.
|
||||
repair := outputRepairFrom(ctx)
|
||||
if message, ok := repair.followUp(text); ok {
|
||||
c.settled = false
|
||||
if _, err = c.rpc(ctx, "prompt", map[string]any{"message": message}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
reply, err := c.settleTurn(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text = repair.merge(text, reply)
|
||||
}
|
||||
return text, nil
|
||||
}
|
||||
|
||||
// settleTurn waits for the prompted Pi turn to settle, records its session
|
||||
// usage and returns the final assistant text.
|
||||
func (c *PiClient) settleTurn(ctx context.Context) (string, error) {
|
||||
for !c.settled {
|
||||
if _, err = c.receive(ctx); err != nil {
|
||||
if _, err := c.receive(ctx); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user