cron: infer payload kind for model-only update patches#15664
Conversation
| const hasAgentTurnHint = | ||
| typeof next.model === "string" || | ||
| typeof next.thinking === "string" || | ||
| typeof next.timeoutSeconds === "number" || | ||
| typeof next.allowUnsafeExternalContent === "boolean" || | ||
| typeof next.deliver === "boolean" || | ||
| typeof next.channel === "string" || | ||
| typeof next.to === "string" || | ||
| typeof next.bestEffortDeliver === "boolean"; |
There was a problem hiding this comment.
Over-broad kind inference
coercePayload now infers payload.kind = "agentTurn" when any of channel, to, deliver, or bestEffortDeliver are present. Those are legacy delivery hints and can plausibly appear on non-agentTurn patches (or accidental/unknown fields) and will now force the patch down the agentTurn schema path. This can cause previously-rejected payload patches to be accepted as agentTurn even when the caller didn’t intend to set/patch an agentTurn payload. Consider narrowing the inference to truly agent-turn-only fields (e.g. model/thinking/timeoutSeconds/allowUnsafeExternalContent) or otherwise gate it so delivery-only hints don’t flip the payload kind by themselves.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cron/normalize.ts
Line: 77:85
Comment:
**Over-broad kind inference**
`coercePayload` now infers `payload.kind = "agentTurn"` when *any* of `channel`, `to`, `deliver`, or `bestEffortDeliver` are present. Those are legacy delivery hints and can plausibly appear on non-agentTurn patches (or accidental/unknown fields) and will now force the patch down the agentTurn schema path. This can cause previously-rejected payload patches to be accepted as `agentTurn` even when the caller didn’t intend to set/patch an agentTurn payload. Consider narrowing the inference to truly agent-turn-only fields (e.g. `model`/`thinking`/`timeoutSeconds`/`allowUnsafeExternalContent`) or otherwise gate it so delivery-only hints don’t flip the payload kind by themselves.
How can I resolve this? If you propose a fix, please make it concise.00f37c2 to
aa14356
Compare
aa14356 to
bb4cc9d
Compare
|
PR #15664 - cron: infer payload kind for model-only update patches (#15664) Merged via squash.
Summary
Thanks @rodrigouroz! |
… thanks @rodrigouroz Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check (fails on current origin/main in src/memory/embedding-manager.test-harness.ts; unchanged by this PR) Co-authored-by: rodrigouroz <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
… thanks @rodrigouroz Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check (fails on current origin/main in src/memory/embedding-manager.test-harness.ts; unchanged by this PR) Co-authored-by: rodrigouroz <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
… thanks @rodrigouroz Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check (fails on current origin/main in src/memory/embedding-manager.test-harness.ts; unchanged by this PR) Co-authored-by: rodrigouroz <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
Summary
cron.updatecompatibility for payload patches that include agent-turn fields (for examplepayload.model) without an explicitpayload.kindpayload.kind = "agentTurn"during cron patch normalization when agent-turn-only hints are presentProblem
cron.updatecan receive partial payload patches from clients/tools. When a patch contains only agent-turn fields (likemodel) and omitskind, request validation rejectsit because
payload.kindis required by schema.Root Cause
Cron patch normalization inferred payload kind for message/text cases, but did not infer kind for model/thinking/timeout/delivery-only agent-turn patches.
Fix
normalizeCronJobPatchpath (normalizeCronJobInput->coercePayload) to inferkind: "agentTurn"when kind is missing and payload contains agent-turn-specificfields
kindChanges
src/cron/normalize.tssrc/cron/normalize.test.tskind: "agentTurn"src/gateway/server.cron.e2e.test.tscron.updateaccepts model-only payload patch, keeps existing message, updates modelSafety
payload.kindis missingTesting
pnpm test src/cron/normalize.test.tspnpm vitest run --config vitest.e2e.config.ts src/gateway/server.cron.e2e.test.tsGreptile Overview
Greptile Summary
This PR extends cron patch normalization so
cron.updatecan accept payload patches that only include agent-turn fields (e.g.payload.model) without explicitly providingpayload.kind. The core change is insrc/cron/normalize.tswherecoercePayloadinferskind: "agentTurn"when certain agent-turn “hints” are present, and new unit + e2e tests cover the model-only patch scenario through the gateway handler.Confidence Score: 4/5
channel/to/deliver/bestEffortDeliver) which can unintentionally coerce otherwise-invalid/ambiguous patches into agentTurn payloads. If that broadening is unintended, it should be tightened before merging.Last reviewed commit: bc3d639