Invocation Routing and Isolation
Explain why service/extension calls do not cross agent environments and how env-based routing works in shell scenarios
Invocation Routing and Isolation
This page answers three practical questions:
- Can one agent runtime call
serviceand leak into another agent environment? - Do
service/extensioncalls go through shell by default? - In CLI and shell subprocess scenarios, how do env vars decide which agent endpoint is used?
Short Answer
- In normal operation, calls do not leak across agent environments.
- The main
service/extensionpath is runtime dispatch in-process, not shell execution. - Cross-environment routing usually happens only when
host/portorSMA_SERVER_*is intentionally or accidentally overridden.
Isolation Boundary (Core Principle)
The runtime model is effectively one process bound to one projectRoot:
- One
sma agent onprocess initializes one runtime state. - That runtime is bound to one
rootPath(one agent project directory). serviceandextensioncalls in that process reuse the same runtime state (config/context/logger/model).
So without endpoint overrides, calls stay in the same agent environment.
Main Call Paths (No Shell by Default)
1) CLI -> service / extension
For sma service ... and sma extension ..., the flow is:
- Resolve
projectRootfrom--path - Resolve daemon endpoint (priority listed below)
- Call
/api/services/*or/api/extensions/* - Daemon dispatches to runtime dispatcher actions inside current runtime
This path is HTTP + runtime dispatch, not shell command chaining.
2) service -> extension
When a service calls extensions.invoke(...):
- runtime invoke ports dispatch directly to extension dispatcher
- the call uses the same injected runtime (
context/config/rootPath)
So service -> extension stays in the same process/runtime scope.
Endpoint Resolution Priority
Daemon endpoint resolution order is:
- explicit CLI params:
--host/--port - env vars:
SMA_SERVER_HOST/SMA_SERVER_PORT(thenSMA_CTX_SERVER_*) - current project
ship.json.start.host/port - default:
127.0.0.1:3000
Implications:
- explicit
--host/--portalways wins. - stale
SMA_SERVER_*can redirect calls away from the current project.
Shell Scenarios and Env Routing
The main service/extension path does not require shell, but some business logic can execute shell tools. In that case:
- default shell
workdiris current runtimeprojectRoot(unless explicitly overridden) - subprocess env includes
SMA_CTX_SERVER_HOST/SMA_CTX_SERVER_PORTto target current runtime server - request context ids are also propagated for traceability
So shell commands spawned from a runtime usually route back to that same runtime by default.
When “Crossing Environments” Can Happen
Typical misrouting cases:
- leftover exported
SMA_SERVER_*in terminal - explicit
--host/--portpoints to another daemon - wrong
--pathcauses loading another project'sship.json.start
Quick Troubleshooting Checklist
- Check whether command has explicit
--host/--port - Check
SMA_SERVER_*/SMA_CTX_SERVER_* - Confirm
--pathor current directory points to target project - Run
sma console agentsand verify endpoint/port against your target runtime