Treat JSON-RPC error responses as non-fatal in apply_permission_mode

AcpError::Protocol covers both real transport corruption and clean
JSON-RPC error responses (e.g. -32601 'Method not found'). When an
agent like amp-acp doesn't implement session/set_config_option, the
error was treated as fatal, causing an infinite respawn loop.

Move Protocol out of the fatal arm so it falls through to the
warn-and-continue path. The harness falls back to per-tool
auto-approval, which is the correct behavior.

Amp-Thread-ID: https://ampcode.com/threads/T-019d4e6c-6235-76b4-aaf3-63baf10304d0
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Andrew Kuttig
2026-04-02 18:41:21 -06:00
parent e4f92dc58b
commit 03555dd234

View File

@@ -574,7 +574,6 @@ async fn apply_permission_mode(
Ok(Err(e @ AcpError::Io(_)))
| Ok(Err(e @ AcpError::WriteTimeout(_)))
| Ok(Err(e @ AcpError::Timeout(_)))
| Ok(Err(e @ AcpError::Protocol(_)))
| Ok(Err(e @ AcpError::AgentExited)) => {
tracing::error!(
target: "pool::permission",
@@ -582,7 +581,10 @@ async fn apply_permission_mode(
);
return Err(e);
}
// Application-level errors — agent is fine, just uses default permission mode.
// Application-level errors (including JSON-RPC error responses like
// "method not found" which surface as AcpError::Protocol) — agent is
// fine, just doesn't support this config method. Fall back to
// per-tool auto-approval.
Ok(Err(e)) => {
tracing::warn!(
target: "pool::permission",