fix: harden runtime against panics/races, close path-traversal and fail-open gaps

- Runtime.Run rejects concurrent invocations instead of racing on shared state; panics in tools, hooks, and permission checkers are recovered and surfaced as errors/denials instead of crashing the loop
- AgentSpec.Loop now actually overrides RuntimeDeps.AgentLoop per-agent, as documented
- session.Store validates agent ID / session key as single path components, preventing traversal outside the session directory
- ValidatePathInWorkDir resolves symlinks on the target itself, not just its parent, closing a workspace-escape gap
- bash tool now fails closed on an unrecognized ExecPolicy.Level instead of allowing everything
- browser tool rejects unknown actions instead of silently no-op'ing

Bump README to v0.3.4 and document the AgentSpec.Loop override semantics.
This commit is contained in:
sausheong committed 2026-08-02 10:14:20 +08:00
1 parent 445614757b
commit eb4fa67976
15 files changed
+421 -37

No files matched your search

+4 -3
View File
@@ -46,9 +46,10 @@ type AgentSpec struct {
// Reasoning maps to each provider's native reasoning knob. Use
// llm.ReasoningOff (zero value), Low, Medium, or High.
Reasoning string
// Loop controls the runtime's tool-execution behavior (concurrency
// cap, depth cap, streaming-tools toggle). Zero value ⇒ env-var
// fallback then compiled-in defaults.
// Loop controls the runtime's per-agent tool-execution behavior
// (concurrency cap, depth cap, streaming-tools toggle). Non-zero fields
// and non-nil hooks override RuntimeDeps.AgentLoop; remaining zero values
// inherit the shared setting, then its env/default fallback.
Loop LoopConfig
// MCPServers, when non-empty, are connected by BuildRuntime: each
// server's tools are namespaced ("mcp__<Name>__<tool>") and added