propose(agentic): read agent_workspace_root from request body and persist to state
Neuron Soul CI / build (pull_request) Successful in 7m45s
Neuron Soul CI / build (pull_request) Successful in 7m45s
Completes the UI<->soul contract for #23 (scope file/command tools to an agent workspace root). #23 made the tools read state_get("agent_workspace_root"), but nothing set that key from the desktop UI, so the agent panel's Workspace Folder was cosmetic and tools ran unscoped (default-allow). This reads the root the UI now sends on each agentic request and state_sets it before tool dispatch, so agent_workspace_root() picks it up for the turn. Minimal + pattern-matching (same json_get/state_set shape used throughout chat.el). Empty body field => unscoped (backward-compatible) and preserves the env fallback. FOR WILL'S REVIEW — do not merge without sign-off: - Ownership model: set state from body each turn (so clearing the folder un-scopes) vs. only-when-nonempty. Flagged inline. - Pairs with neuron-ui PR #32 (ChatRequest.agentWorkspaceRoot). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -631,6 +631,17 @@ fn handle_chat_agentic(body: String) -> String {
|
||||
return "{\"error\":\"message required\",\"reply\":\"\"}"
|
||||
}
|
||||
|
||||
// Workspace scope (#23): the desktop UI sends the user-chosen Agent Workspace root
|
||||
// on every agentic request. Persist it to state so agent_workspace_root() — and the
|
||||
// path/command tool guards that read it — confine this turn's file/command tools to
|
||||
// that subtree. The UI is the source of truth per request: empty means unscoped (the
|
||||
// backward-compatible default), and it also lets agent_workspace_root() fall through
|
||||
// to the NEURON_AGENT_ROOT env when no root is sent. FLAGGED FOR REVIEW: setting
|
||||
// state from the body each turn (vs. only-when-nonempty) so clearing the folder in
|
||||
// the UI un-scopes — confirm this is the intended ownership model.
|
||||
let ws_root: String = json_get(body, "agent_workspace_root")
|
||||
state_set("agent_workspace_root", ws_root)
|
||||
|
||||
let req_model: String = json_get(body, "model")
|
||||
let model: String = if str_eq(req_model, "") { chat_default_model() } else { req_model }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user