The memory tools talked to a mem0 server (memory_url/memory_key_env), one bucket per unix user. It is gone: no memory_add, no memory_search, no mem0 client, no config keys, no test_memory. - delete src/backend/memory.c and memory.h; the engine no longer registers the tools; config loses memory_url/memory_key_env; SPLINTER_MEM_KEY leaves the secret list; docs/CONFIG, ROADMAP and GATEWAY stop mentioning it. - the unix identity helper stays, under its real name: sp_user_name() in src/backend/user.c (profiles, interview and the Telegram gateway used it). - tool list is now read/search/list/write/edit/run/skill_*/... plus the MCP session tools; nothing about memory remains. - test_mcpsession.sh: the client socket gets a 120 s read timeout, not the 5 s connect timeout (a turn under load answered too late and looked hung). make check: all tests passed.
5.1 KiB
The OpenAI gateway
splinter --openai-listen IP [--openai-listen-port N] is a small
OpenAI-compatible endpoint. Another harness points its OpenAI client at it and
gets an answer from splinter's configured provider, with tools on both
sides: splinter executes its own tools where splinter runs, the caller
executes its tools where the caller runs.
# the side with the files and the shell
splinter -m myprovider --openai-listen 127.0.0.1 --openai-listen-port 8097
# the other harness
export OPENAI_BASE_URL=http://127.0.0.1:8097/v1
export OPENAI_API_KEY=unused # unless SPLINTER_GATEWAY_TOKEN is set
GET /v1/models answers with the run's model, so a client that probes first is
happy. POST /v1/chat/completions accepts the usual messages, tools and
stream fields.
Two tool namespaces
The model sees two kinds of tools in one request:
| name | who runs it | where |
|---|---|---|
gw_read, gw_write, gw_edit, gw_run, … |
splinter | on the host where splinter runs |
everything in the caller's tools array |
the calling harness | where the harness runs |
gw_ is reserved: a caller tool with that prefix is refused with HTTP 400,
because that is how a local read and a caller's read stay apart.
The loop, inside one HTTP request:
- splinter asks its provider with the caller's conversation, the caller's
tools and its own tools renamed
gw_*. - If the model calls
gw_*, splinter runs it here (read tools always; mutating and destructive ones only with--autonomous), appends the observation and asks the provider again. The caller never sees these calls. - If the model calls a caller tool, splinter returns a normal
chat.completionwithtool_callsandfinish_reason: "tool_calls". The harness runs them, sends the results astoolmessages in the next request, and the gateway continues. - If a reply mixes both, the local calls run here and the caller's calls are
returned in the same
tool_callsanswer. Since the caller cannot answer agw_call, the local observations travel in the messagecontent(under "local gateway tools ran on the splinter host:"); the caller sends them back with the assistant message as usual, and the model sees both sides.
Every request is stateless, as the OpenAI protocol says: the conversation travels with it. The loop is capped at 16 local tool rounds and each observation at 32 KiB.
Request shaping
The caller's temperature, top_p and max_tokens (or
max_completion_tokens) are forwarded to the provider; absent values stay the
provider's default. The response echoes the request's model name, and every
message, including the mixed-reply case, stays within the OpenAI chat shape.
Bodies may arrive with Content-Length or Transfer-Encoding: chunked; only
one request per connection is read, then the connection closes.
Streaming
With "stream": true the gateway uses the provider's streaming transport and
forwards each text delta as a chat.completion.chunk event while it arrives -
the caller sees the answer grow instead of waiting for the last token. The
caller's tool calls are sent as one tool_calls delta at the end of the step,
because a name is only complete when the provider has finished it; local
gw_* calls stay invisible. "stream_options":{"include_usage":true} adds a
final usage chunk before [DONE], with the token counts summed over every
upstream round of the request.
If the provider fails after the stream has started, the stream carries an
{"error":...} object and [DONE]; a request that was invalid before the
first byte is still an ordinary HTTP 400. The gateway ignores SIGPIPE, so a
caller that closes its stream early cannot kill the server.
Examples
A local tool, executed by splinter, from the caller's point of view an ordinary completion:
curl -s http://127.0.0.1:8097/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"x","messages":[{"role":"user","content":"read Cargo.toml"}]}'
A caller tool comes back instead:
{"choices":[{"index":0,"message":{"role":"assistant","content":"",
"tool_calls":[{"id":"c1","type":"function",
"function":{"name":"browser_open","arguments":"{\"url\":\"...\"}"}}]},
"finish_reason":"tool_calls"}]}
Security
- Beyond loopback the server refuses to start without
SPLINTER_GATEWAY_TOKEN; with a token set, every request needsAuthorization: Bearer <token>. --autonomousis the switch that lets the model usegw_write,gw_editandgw_run. Without it those calls are denied with an observation the model reads, so it can still answer.- There is no TLS. Expose it through ssh, WireGuard or a TLS proxy when the network is not yours.
- One request is served at a time; the endpoint is a gateway, not a load balanced service.
Where the tools come from
gw_* is the engine's registry: the builtins (read, write, edit,
search, list, run, websearch, webfetch), folder_history,
delegate, and the skills tools. Plugins loaded with --plugin add
theirs. The caller's tools are passed through to the provider untouched, except
for the gw_ reservation.