Merge feature/ticket95-opencode-mcp-timeout into develop
This commit is contained in:
@ -2645,6 +2645,31 @@ fn mcp_server_wiring(
|
|||||||
///
|
///
|
||||||
/// The MCP server is named `idea`; OpenCode therefore exposes IdeA tools as
|
/// The MCP server is named `idea`; OpenCode therefore exposes IdeA tools as
|
||||||
/// `idea_idea_*` (`<serverName>_<toolName>`), matching the observed contract.
|
/// `idea_idea_*` (`<serverName>_<toolName>`), matching the observed contract.
|
||||||
|
/// Default MCP request timeout (milliseconds) injected into the OpenCode agent
|
||||||
|
/// config (`opencode.json` → `mcp.idea.timeout`). OpenCode applies this **per
|
||||||
|
/// `tools/call`** to its MCP servers; the original hardcoded `15_000` (15 s) was
|
||||||
|
/// far too short for `idea_ask_agent`, which blocks while the target agent works
|
||||||
|
/// (potentially minutes). Aligning on the rendezvous ceiling (4 h) ensures
|
||||||
|
/// OpenCode's client never kills an in-flight delegation before the server-side
|
||||||
|
/// watchdog resolves.
|
||||||
|
///
|
||||||
|
/// **Must stay ≥ `DEFAULT_RENDEZVOUS_CEILING`** so the MCP client timeout and the
|
||||||
|
/// server-side absolute ceiling expire together — never the client first.
|
||||||
|
/// Overridable via `IDEA_OPENCODE_MCP_TIMEOUT_MS`.
|
||||||
|
pub const DEFAULT_OPENCODE_MCP_TIMEOUT_MS: u64 = 4 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
/// Resolves the effective OpenCode MCP request timeout (ms) from the
|
||||||
|
/// `IDEA_OPENCODE_MCP_TIMEOUT_MS` env var, falling back to
|
||||||
|
/// [`DEFAULT_OPENCODE_MCP_TIMEOUT_MS`]. Parse failure or `0` ⇒ default, so a
|
||||||
|
/// misconfigured value never collapses the timeout to an instant kill.
|
||||||
|
pub fn resolve_opencode_mcp_timeout_ms() -> u64 {
|
||||||
|
std::env::var("IDEA_OPENCODE_MCP_TIMEOUT_MS")
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| v.trim().parse::<u64>().ok())
|
||||||
|
.filter(|&ms| ms > 0)
|
||||||
|
.unwrap_or(DEFAULT_OPENCODE_MCP_TIMEOUT_MS)
|
||||||
|
}
|
||||||
|
|
||||||
fn opencode_config_json(
|
fn opencode_config_json(
|
||||||
config: &domain::profile::OpenCodeConfig,
|
config: &domain::profile::OpenCodeConfig,
|
||||||
project_root: &str,
|
project_root: &str,
|
||||||
@ -2725,7 +2750,7 @@ fn opencode_config_json(
|
|||||||
"command": command_array,
|
"command": command_array,
|
||||||
"cwd": project_root,
|
"cwd": project_root,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"timeout": 15000
|
"timeout": resolve_opencode_mcp_timeout_ms()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -2808,7 +2833,7 @@ fn opencode_provider_config_json(
|
|||||||
"command": command_array,
|
"command": command_array,
|
||||||
"cwd": project_root,
|
"cwd": project_root,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"timeout": 15000
|
"timeout": resolve_opencode_mcp_timeout_ms()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -40,7 +40,8 @@ pub use lifecycle::{
|
|||||||
ListAgentsOutput, LiveStateLeanProvider, McpRuntime, PermissionProjectorRegistry,
|
ListAgentsOutput, LiveStateLeanProvider, McpRuntime, PermissionProjectorRegistry,
|
||||||
ProviderSessionProvider, ReadAgentContext, ReadAgentContextInput, ReadAgentContextOutput,
|
ProviderSessionProvider, ReadAgentContext, ReadAgentContextInput, ReadAgentContextOutput,
|
||||||
StructuredRoutingMode, StructuredSessionDescriptor, UpdateAgentContext,
|
StructuredRoutingMode, StructuredSessionDescriptor, UpdateAgentContext,
|
||||||
UpdateAgentContextInput, AGENT_MEMORY_RECALL_BUDGET, LIVE_STATE_INJECT_MAX,
|
UpdateAgentContextInput, DEFAULT_OPENCODE_MCP_TIMEOUT_MS, AGENT_MEMORY_RECALL_BUDGET,
|
||||||
|
LIVE_STATE_INJECT_MAX, resolve_opencode_mcp_timeout_ms,
|
||||||
};
|
};
|
||||||
pub use resume::{
|
pub use resume::{
|
||||||
ListResumableAgents, ListResumableAgentsInput, ListResumableAgentsOutput, ResumableAgent,
|
ListResumableAgents, ListResumableAgentsInput, ListResumableAgentsOutput, ResumableAgent,
|
||||||
|
|||||||
@ -407,7 +407,7 @@ fn opencode_config_json(
|
|||||||
"command": command_array,
|
"command": command_array,
|
||||||
"cwd": project_root,
|
"cwd": project_root,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"timeout": 15000
|
"timeout": application::agent::resolve_opencode_mcp_timeout_ms()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -492,7 +492,7 @@ fn opencode_provider_config_json(
|
|||||||
"command": command_array,
|
"command": command_array,
|
||||||
"cwd": project_root,
|
"cwd": project_root,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"timeout": 15000
|
"timeout": application::agent::resolve_opencode_mcp_timeout_ms()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user