fix(auto-reply): thread per-agent tools.exec defaults into reply directives#57689
fix(auto-reply): thread per-agent tools.exec defaults into reply directives#57689jacobtomlinson merged 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR correctly fixes a bug where per-agent Key observations:
Confidence Score: 5/5Safe to merge — the logic change is small, correct, and adds a missing fallback without disturbing existing priority ordering. All remaining findings are P2 (style/test coverage suggestions). The implementation correctly uses nullish coalescing to chain the new fallback at the lowest priority, matching the stated design. No critical bugs or data-integrity issues were found. No files require special attention, though reply.directive.exec-agent-defaults.test.ts would benefit from precedence-inversion test cases and an explicit routing comment.
|
| Filename | Overview |
|---|---|
| src/auto-reply/reply/get-reply-directives.ts | Adds agentEntry as an optional third fallback in resolveExecOverrides using nullish coalescing; correctly maintains directive > session > agent priority order. |
| src/auto-reply/reply.directive.exec-agent-defaults.test.ts | New integration test verifying the agent-entry exec defaults path; covers happy path but lacks precedence-inversion assertions and has an implicit routing dependency. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/auto-reply/reply.directive.exec-agent-defaults.test.ts
Line: 55-79
Comment:
**Missing precedence coverage for the new fallback layer**
The new test only validates the happy path (all four fields set, no directive/session in play). Two important guard scenarios are unverified:
1. **Directive takes precedence over agent entry** — an inline directive for `host` should still win over `agentEntry.tools.exec.host`.
2. **Session override takes precedence over agent entry** — a persisted `sessionEntry.execHost` should still win over the agent default.
Without these, a future refactor that accidentally swaps the priority order (`agentEntry` wins over `sessionEntry`, or similar) will go undetected. Given that the PR description calls out priority ordering as a correctness guarantee ("Session-level overrides and inline directives still take precedence"), locking it in with at least one priority inversion test is worthwhile.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/auto-reply/reply.directive.exec-agent-defaults.test.ts
Line: 18-42
Comment:
**Test config omits an explicit agent ID match — routing dependency is implicit**
`makeAgentExecConfig` names the single agent `"main"` but the mock message carries no `AgentId`/`To`-to-agent routing configuration. The test silently relies on the system defaulting to `"main"` for an unrouted WhatsApp message.
If the default agent name ever changes (or the routing default is altered), this test will silently stop exercising the agent-entry path — `agentEntry` will resolve to `undefined`, `execOverrides` will be `undefined`, and the `expect` at line 73 will fail with a cryptic mismatch rather than a clear routing assertion.
Consider adding a comment or a `From`/`To` routing rule in the config to make the dependency explicit, e.g.:
```ts
channels: {
whatsapp: {
allowFrom: ["*"],
// Routes all traffic to the "main" agent so agentEntry resolution is deterministic
agentId: "main",
},
},
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(auto-reply): thread per-agent tools...." | Re-trigger Greptile
…tests for exec agent defaults
…ctives (openclaw#57689) * fix(auto-reply): thread per-agent tools.exec defaults into exec overrides * test(auto-reply): add session-override and inline-directive priority tests for exec agent defaults
…ctives (openclaw#57689) * fix(auto-reply): thread per-agent tools.exec defaults into exec overrides * test(auto-reply): add session-override and inline-directive priority tests for exec agent defaults
Summary
tools.execconfiguration (host,security,ask,node) inagents.list[].tools.execwas silently ignored at reply time — only inline directives and session overrides were consulted, so per-agent exec defaults never took effect.resolveExecOverridesnow accepts an optionalagentEntryand falls back toagentEntry.tools.exec.*after directive and session resolution; the resolved entry is threaded in fromresolveReplyDirectives.Also included: task registry maintenance hardening —
markTaskLostnow stampscleanupAfterin the same pass as the status transition, preventing orphaned tasks from persisting indefinitely after a maintenance sweep.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
resolveExecOverridesonly read fromdirectivesandsessionEntry; theagentEntrylookup existed inresolveReplyDirectivesbut was never passed down.resolveReplyDirectivesfor other purposes (reasoning defaults, model selection) but the exec override helper predated the agent-entry threading.Regression Test Plan (if applicable)
src/auto-reply/reply.directive.exec-agent-defaults.test.tsagents.list[].tools.execset and no session override must surface those values in theexecOverridespassed torunEmbeddedPiAgentMock.User-visible / Behavior Changes
Per-agent
tools.execdefaults (host,security,ask,node) now apply when no inline directive or session override is present. Previously these were silently ignored.Diagram (if applicable)
Security Impact (required)
tools.exec.securityortools.exec.hostwas set with the expectation it would be ignored, it will now enforce. This matches declared intent.Repro + Verification
Environment
agents.list[].tools.execwith all four fields setSteps
tools.exec.host,security,ask,node.execOverridesin the embedded Pi agent call.Expected
execOverridesreflects the agent-level config values.Actual (before fix)
execOverrideswasundefined(all agent defaults silently dropped).Evidence
src/auto-reply/reply.directive.exec-agent-defaults.test.tsasserts the corrected behavior.Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations
tools.execconfig; any such config was already user-declared intent.