Repository navigation
Agents: add inferred commitments - #74189
Conversation
🔒 Aisle Security AnalysisWe found 4 potential security issue(s) in this PR:
1. 🟡 Heartbeat commitment delivery bypasses configured `heartbeat.target: "none"` causing unintended outbound messages
DescriptionIn
Vulnerable code: const heartbeatForDelivery = commitmentDeliveryContext
? { ...heartbeat, target: "last", to: undefined, accountId: undefined }
: heartbeat;
const delivery = resolveHeartbeatDeliveryTarget({
...,
heartbeat: heartbeatForDelivery,
turnSource: commitmentDeliveryContext ? commitmentDeliveryContext : ...,
});A new test explicitly asserts this behavior ( RecommendationEnsure commitment delivery respects the operator’s heartbeat delivery disable switch. Options:
const configuredTarget = heartbeat?.target ?? cfg.agents?.defaults?.heartbeat?.target;
const commitmentDeliveryContext = firstDueCommitment ? { ... } : undefined;
const hasCommitments = Boolean(commitmentDeliveryContext);
if (hasCommitments && configuredTarget === "none") {
// do not send anything
return { status: "skipped", reason: "target-none" };
}
2. 🟡 Unbounded commitment extraction queue enables memory/cost DoS via repeated inbound messages
DescriptionThe commitments feature enqueues an extraction item for (nearly) every non-heartbeat turn, and the in-memory queue is unbounded.
Vulnerable code: let queue: Array<...> = [];
...
export function enqueueCommitmentExtraction(input: CommitmentExtractionEnqueueInput): boolean {
...
queue.push({ ... });
...
}RecommendationAdd backpressure controls to the background extraction queue. Minimum safe changes:
Example approach (global cap + per-scope coalescing): const MAX_QUEUE_ITEMS = 200;
const queueByScope = new Map<string, Omit<CommitmentExtractionItem, "existingPending"> & { cfg?: OpenClawConfig }>();
export function enqueueCommitmentExtraction(input: CommitmentExtractionEnqueueInput): boolean {
...
const scopeKey = `${input.agentId}\u001f${input.sessionKey}\u001f${input.channel}\u001f${input.to ?? ""}\u001f${input.senderId ?? ""}`;
const item = { /* hydrated item fields */ };
// Coalesce: keep only latest per scope within debounce window
queueByScope.set(scopeKey, item);
// Enforce global cap
if (queueByScope.size > MAX_QUEUE_ITEMS) {
// drop oldest or random eviction; ensure deterministic policy
// e.g., delete first inserted key if using Map insertion order
const oldestKey = queueByScope.keys().next().value;
if (oldestKey) queueByScope.delete(oldestKey);
}
scheduleDrain();
return true;
}
export async function drainCommitmentExtractionQueue(): Promise<number> {
const batch = [...queueByScope.values()].splice(0, resolved.extraction.batchMaxItems);
...
}This prevents unbounded memory growth and limits how much work/cost can be forced by rapid inbound messaging. 3. 🟡 Commitment heartbeat delivery bypasses heartbeat.target="none" and can send inferred personal check-ins to chat recipients
Description
This means even when an operator configures Vulnerable behavior:
Vulnerable code: const heartbeatForDelivery = commitmentDeliveryContext
? { ...heartbeat, target: "last", to: undefined, accountId: undefined }
: heartbeat;
const delivery = resolveHeartbeatDeliveryTarget({
cfg,
entry,
heartbeat: heartbeatForDelivery,
turnSource: commitmentDeliveryContext ? commitmentDeliveryContext : ...,
});RecommendationRespect Options:
const heartbeatForDelivery =
commitmentDeliveryContext && heartbeat?.target !== "none"
? { ...heartbeat, target: "last", to: undefined, accountId: undefined }
: heartbeat;
Also consider adding a guard before sending: if (heartbeat?.target === "none") {
// skip commitment delivery and mark as attempted/left pending, or explicitly dismiss
return { status: "skipped", reason: "target-none" };
}This ensures operators can reliably prevent automatic outbound messages to external chat recipients. 4. 🔵 Sensitive session transcripts written to extractor session JSONL without explicit restrictive file permissions
Description
Vulnerable code: sessionFile: resolveExtractionSessionFile(first.agentId, runId),and return path.join(resolveStateDir(), "commitments", "extractor-sessions", agentId, `${runId}.jsonl`);RecommendationEnsure extractor session directories and files are created with restrictive permissions before use. Example approach (best-effort): import fs from "node:fs/promises";
import path from "node:path";
async function ensurePrivateSessionFile(sessionFile: string) {
await fs.mkdir(path.dirname(sessionFile), { recursive: true, mode: 0o700 });
const fh = await fs.open(sessionFile, "a", 0o600); // create if missing
await fh.close();
}
// before runEmbeddedPiAgent(...)
const sessionFile = resolveExtractionSessionFile(first.agentId, runId);
await ensurePrivateSessionFile(sessionFile);Also consider documenting the retention policy for these extractor sessions and/or pruning old runs. Analyzed PR: #74189 at commit Last updated on: 2026-04-29T08:40:42Z |
Greptile SummaryThis PR adds an inferred-commitments system: after each non-heartbeat reply, conversation turns are asynchronously fed to a hidden LLM extractor (tools disabled, batched) to produce per-agent/per-channel follow-up commitments stored in a flat JSON file. Due commitments are injected into heartbeat prompts and marked sent/dismissed on completion. A new
Confidence Score: 3/5Not safe to merge until the prompt injection risk in heartbeat delivery is addressed. A P1 security finding (user-controlled text injected into a tool-capable agent prompt) caps the score at 4, and the missing mitigation in a security-sensitive path warrants pulling the score one point below the ceiling. src/infra/heartbeat-runner.ts (buildCommitmentHeartbeatPrompt — delivery prompt injection) and src/commitments/store.ts (upsertInferredCommitments — redundant save branches).
|
|
Codex review: needs maintainer review before merge. Keep this PR open. It is an open, unmerged XL feature PR with the protected Maintainer follow-up before merge: Keep this PR open for explicit maintainer/product/security review. The best path is to decide the product boundary for inferred commitments, then require review of defaults, privacy/data retention, prompt-injection boundaries, queue/store backpressure, config/docs/changelog surfaces, and Testbox/CI proof before landing or replacing the branch. Best possible solution: Keep this PR open for explicit maintainer/product/security review. The best path is to decide the product boundary for inferred commitments, then require review of defaults, privacy/data retention, prompt-injection boundaries, queue/store backpressure, config/docs/changelog surfaces, and Testbox/CI proof before landing or replacing the branch. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9bb1e59447a5. |
ab68f31 to
fcff37e
Compare
fcff37e to
9b73ef9
Compare
9b73ef9 to
2f431c1
Compare
2f431c1 to
4f77c96
Compare
Summary
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A
Regression Test Plan (if applicable)
N/A
User-visible / Behavior Changes
Agents can now infer follow-up commitments by default, store them per agent/channel, deliver due items through heartbeat, and expose
openclaw commitmentsmanagement commands. Newcommitments.*config controls allow opting out or tuning extraction and delivery.Diagram (if applicable)
Security Impact (required)
Yes/No) YesYes/No) NoYes/No) YesYes/No) NoYes/No) YesYes, explain risk + mitigation: Hidden extraction uses the existing model provider path but runs tool-disabled and outside the visible conversation transcript. Stored commitments are scoped by agent/channel/account/thread target and can be disabled through config.Repro + Verification
Environment
Steps
Expected
Actual
pnpm check, andpnpm buildpassed locally.Evidence
Human Verification (required)
pnpm testis not green locally due to pre-existing unrelated failures in plugin staging/acpx/memory tests.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) YesYes/No) Nocommitments.enabled=falseto opt out.Risks and Mitigations