P304 · Context management

Durable behavioral agent contract

Describe behavior and named interfaces instead of volatile file locations in delayed task handoffs.

Editorially reviewed

These examples and illustrative results are independently authored teaching materials, not measured model results.

Use case

Queue a CLI JSON-output fix for next week while files may be renamed. Teaching interface reportResult(result,options) serves a query command; success emits JSON but failure plain text. Under –json both must parse, retaining success exit 0 and failure exit 1.

Mechanism

State current/desired behavior, independently verifiable inputs/outputs and scope, with stable interface names and revision context. Lines can document current observations but should not be the sole requirement. The recipient locates the current interface, repairs behavior and runs acceptance checks despite file moves.

Bad example

Next week open handler.ts line 80 and add a switch. That completes the JSON-output fix without specifying failure output or exit codes.

Good example

Fix reportResult for the query command: under --json, success and failure both emit parseable JSON; retain exit codes 0/1 and identifiable error information. Preserve non-JSON behavior and other commands. Locate the interface in current code, then check JSON parsing and exit status for success and failure inputs. A current path is a clue, not the behavioral contract.

Why the change matters

Location-only instructions depend on current structure without specifying what completion means. A stable interface plus the observable behavior change survives moves; independent acceptance cases establish whether the original problem was solved.

Observable expectation

Capture stdout and exit status for one successful and one failed query. Under –json both parse, with status 0 and 1 respectively; ordinary output retains its contract.

After renaming the interface file, the brief should still identify the objective. A switch alone, success-only repair or failure exit 0 fails the check.

Limits

Behavior contracts still need current revision/interface validation, and names can also change. Precise paths remain useful for immediate evidence; the method avoids making temporary locations the only durable requirement.

Sources and evidence

Read the editorial criteria