12 Commits
Author SHA1 Message Date
lotherk 74df75d438 no approval gate: splinter runs what the operator's registry offers
Konrad, 24.11.: "v1 geht durch ohne irgendwas. ich will auch keine approvals
generell. ich will nur das der user mit ask nach sachen gefragt werden kann."

Removed the whole approval apparatus, not just the prompt:

- agent.c: the decision point (sp_host_gate/approve callbacks), the
  pause/resume path (has_pending, pending_from, sp_agent_resume), ack_approval,
  ask_operator and the ack stdin thread are gone. A tool runs; its exit status
  is the observation. sp_tool_policy (allow/deny per profile) stays - that is
  the operator's own configuration, not a question to the operator.
- engine.c: SP_EV_APPROVAL, sp_engine_approve, the approve_pending condition
  variable and the `approval`/`approve` protocol commands are gone.
- openai_server.c: the v1 endpoint runs gw_* tools without a gate; the
  autonomous flag is no longer part of sp_gateway_opts.
- a2aserver.c: INPUT_REQUIRED and the resume-by-taskId path are gone; CancelTask
  stays. An A2A caller has no operator sitting in front of a prompt.
- mcpserver.c: --autonomous no longer gates mutating tools; the flag and the
  config key are accepted for compatibility and documented as changing
  nothing.
- telegram.c: tg_approve and the approval callback are gone; ask is the only
  dialog, and /cancel inside it still ends the turn.
- front ends: protocol.c, curses.c, ui_local.c, ui_remote.c, client.c lose the
  approval event and the waiting flag.
- ack.c stays: it is a plugin API (plugins/kids asks its parent through it),
  not splinter's own gate. --ack is documented as such.

Tests: test_pause.c guarded the pause and now guards the opposite (a mutate and
a destructive tool run, nothing is asked). test_a2a_input.sh, test_protocol.sh,
test_ui.sh, test_agents_ui.sh, test_gateway.sh, test_gateway_openai.sh,
test_agent.c and test_mcpsession.sh were rewritten the same way;
splinter_approve must now be absent from the MCP tool list. Every rewritten
test was run red against the old behaviour where that was possible.

make check: all tests passed (428 s)
make check-asan: all 47 test binaries clean
make check-tsan: all 47 test binaries free of data races
2026-11-24 11:46:10 +00:00
lotherk 082223af96 agent: a step that reports no usage does not empty the ctx meter
The guard was there since 16.11. ("keep the last known prompt size, or the
status bar drops to 0 after every tool call") but nothing tested it, so
t0429 stayed open on the one point that had no evidence.

usage_gap_send reports 1000 prompt tokens on the call that starts the round,
9000 on the next, and nothing at all on the answer. Without the guard
last_in becomes 0 on that answer; with it the meter keeps 9000 and the cache
figure 4000, while tokens_in still sums what was actually reported.

Evidence: make check exit 0 (45 binaries + 20 shell tests), tests/check_asan.sh
all 45 clean. Counter-check: with the old unconditional
`last_in = reply.tokens_in > 0 ? ... : 0`, test_agent fails on
last_in == 9000 and last_cached == 4000.

The other four points of t0429 are covered elsewhere and were verified:
the goal sidecar and /continue in test_session.c and test_engine.c, the
plain sidebar page in test_theme.c (flat light/dark: bg white/black, fg the
opposite, input on the same page), and sysinfo was dropped on purpose in
t0469.
2026-11-22 15:27:54 +00:00
lotherk d714efb16e agent: a broken tool call gets five corrected tries, then words
Konrad saw "agent: model sent malformed tool arguments" on the Telegram
daemon again and again. The retry existed, but it was useless: three
attempts in a single millisecond, each with the identical prompt, so the
model answered with the identical broken call. After the third the turn
died with an error nobody can act on, and the session lost the work.

Now:

- Five tries, five seconds apart (SPLINTER_RETRY_WAIT_MS still shortens
  it for the tests). The wait goes through retry_sleep(), so Ctrl-C does
  not have to sit it out.
- Every retry carries a correction as a user message: what was wrong,
  and what to send instead. A tool result without a call before it is
  refused by the endpoint, so it has to be a user turn.
- A call cut off by the token limit is a different fault from a call the
  model could not write. sp_reply grew a `finish` field ("length",
  "max_tokens"), filled by both the SSE parser and the non-streaming
  reply; the correction then asks for a *smaller* call instead of the
  same one the limit already truncated.
- After the fifth failed try the turn does not die: the model is asked
  for plain words ("say what you wanted to do, step by step"), and
  whatever it sends ends the turn as an answer. A call that arrives
  anyway does not run and is logged whole.
- The log line keeps the whole argument string, not 240 bytes of it -
  "mal gucken" means the operator can read what the model tried.

The tests were only rebuilt when their .c changed, so a new field in
struct sp_reply left them reading a different layout; that failure looks
like a broken test, not a stale object. $(TESTS) now depend on $(HDRS).

Evidence: make check exit 0 (45 binaries + 20 shell tests,
SPLINTER_RETRY_WAIT_MS=0). Counter-checks: with the old single-prompt
retry test_agent fails on bad_args_calls == 6 and on the correction
text; without the finish field cut_off_second carries "not valid JSON"
instead of "cut off by the".
2026-11-22 14:46:08 +00:00
lotherk f7120882fa sessions: a resumed session is the whole transcript, not a chat log
A session file was written as if it were a chat: role and text, nothing
else. Reading it back kept "user" and "assistant" and dropped everything
else - and nearly every line of an agent transcript is an observation.
Measured on three real sessions: 21 of 1507 messages came back, 8 of 1356,
3 of 317. --resume then sent 1% of the conversation and the model had no
idea what it was continuing.

Three writers had to change with the loader:

  - A turn that asked for tools wrote no line at all (agent.c only wrote
    when ncalls == 0). It now goes out with its tool_calls, and each result
    with the name of its tool and its call id; a provider rejects a tool
    message without them.
  - {"role":"user","text":""} came from the steer path and showed the model
    a blank human turn it answered. sp_session_append_rec writes nothing
    when text and calls are both empty.
  - A record from the old format has no name and no call id. It is paired
    with the next unanswered call of its pending assistant turn, or given a
    synthetic one (recovered-N). Dropping it is what emptied every resume;
    keeping it unpaired is what a provider answers with 400.

The same pass gives the core its own compactor (compact.c): a thread digest
- one line per dropped message, OPERATOR: 800 chars, assistant: 300, tool
result 160 - so the model keeps the story, not a count. lcm stays a plugin
that runs after it; sp_core_compactor() is the fallback only when no plugin
registered one, because running both eats the conversation before lcm sees
work to do.

Two bugs fell out of the same area:

  - The plugin host was only built when a plugin was configured, so a
    plugin-less run had no compactor at all: over max_bytes the turn was
    refused instead of compacted (90 KB session, budget 8000, "nothing
    sent").
  - lcm walked *forward* past tool results at the tail boundary, which
    silently shrank the tail: a turn with two results kept four messages
    where keep_tail says six. Walking back to the assistant that carries
    the call keeps six and no orphan.

And the .meta sidecar is shared now: the core rewrote it with only the keys
it knew, so anything a plugin put there was gone on the next open. It
carries unknown lines through (extra[8][160]), which is what lets a plugin
mark a session in the core's own file.

Tests: tests/test_corecompact.c (10 checks, no plugin), the resume cases in
tests/test_session.c, and the tail-size check in tests/test_compactor.c.
Each was seen red on the old code before it was green on the new.
2026-11-21 21:25:51 +00:00
lotherk 4cbd57d829 tree: lcm keeps the task, and the in-flight work it sits in
Everything that was uncommitted in the shared tree, in one commit because the
changes are interleaved across the same files (lcm, engine, frontend, locales).

lcm: a continuation prompt is not the task. After /resume the newest user
message is "Continue with the task ...", and pinning it kept the keystroke
while the question it continues was cut away -- measured: a resumed session
woke up with the prompt, one tool call and its error, and no task at all. The
pin now skips the harness's own continuation prompts, so the real question is
pinned again. test_compactor drives it: with the skip disabled the task is
lost (red), with it the task comes back after the summary (green).

engine: /self-check and the exact tool-argument parse are in a1794fb; this
commit carries the tests for them (a failed tool observation must appear in
the self-check prompt; mcp_parse_exact rejects two objects in one string) and
the i18n keys the new code uses: cmd.script.*, main.no_profile, tg.busy,
tg.interview.running, ui.agent_busy in all three catalogues.

The rest is the in-flight work from the shared session: engine/frontend,
plugins, telegram/a2a, and their tests.

make check: all tests passed; check_i18n ok, 204 keys in 3 catalogues.
2026-11-18 23:03:09 +00:00
lotherk a1794fb101 engine: /self-check, and tool arguments must be one JSON object
/self-check (and /selfcheck) takes the last three turns of the conversation,
every failed tool result in them and the last turn's error, and starts a turn
with them: something went wrong, check yourself instead of asking the
operator, name the cause and continue. Messages are capped per message and in
total, oldest dropped first; it is refused mid-turn like /compact and is in
the completion list.

mcp_parse() stops at the closing brace, so a tool-call argument string holding
two objects parsed as the first one and the second command disappeared without
a word -- measured in sess-1795032073, where "cat a" ran and "cat b" was
silently dropped. mcp_parse_exact() requires the whole text to be the one
value; the agent's tool-argument validation uses it, so such a reply is
retried and then fails with "model sent malformed tool arguments" instead of
running half the command.

test_engine drives both spellings and the included turn; test_agent drives the
joined-argument reply (three requests, zero tool calls). test_engine and
test_agent pass; the build is -Wall -Wextra -Werror clean.
2026-11-18 21:54:04 +00:00
lotherk 6b560e63a0 agent: validate tool-call arguments before they enter the conversation
A model step with arguments like "{command:cd ..." is not JSON. Splinter
accepted it, ran "sh -c {command:cd ..." (exit 127), then sent the bad
assistant tool_call back on the next request: every endpoint answered 500
"Failed to parse tool call arguments as JSON" and junction cooled all four.

Arguments that start with '{' must parse now. If they do not, the reply is
freed without adding the assistant message or running a tool; the request is
retried up to three times and then fails with "model sent malformed tool
arguments". A bare string (mock/script shape) is still allowed.

test_agent drives a transport with exactly that malformed call: three requests,
zero tool calls, no "command:bad" in the conversation.

make check: all tests passed.
2026-11-18 15:45:42 +00:00
lotherk 63b6742447 retry reasoning-only streams, /compact, token threshold and target
- a stream that carried only reasoning and then ended without an answer used to
  abort with no retry: guarded_stream counted every chunk as "already
  produced". Only answer text and tool calls block a retry now; the thinking
  may repeat, a lost turn may not. test_agent has a stream that thinks, fails
  once and answers on the second attempt.
- /compact [tokens]: runs the compactors now (default: compact_target, else
  8000 tokens) and reports messages and bytes before/after.
- compact_threshold / compact_target in core (tokens): once the last request
  was larger than the threshold, the next request is compacted to the target
  before it is sent. 0 disables either.
- lcm gains a read tool `recall`: case-blind search in the session log for
  what compaction dropped from the prompt.
- user config: compact_threshold = 32000, compact_target = 12000.
- README/CONFIG document the command, the two keys and the cache trade-off.

make check: all tests passed.
2026-11-17 21:34:57 +00:00
lotherk 7e8fe5b825 retries are visible in the prompt line
The session showed the last error as "retry 1/3 in 5000ms: openai: stream
ended with no answer" with nothing on screen: the turn looked hung for the
five seconds, then either answered or failed. The retry itself was fine; the
operator could not see it.

- sp_agent_config gains note()/note_ctx: a status line for the operator, ""
  clears it. The engine turns it into SP_EV_NOTE, so curses shows it in the
  steer line and protocol clients get the note event.
- agent_request() emits "retrying in N s: <reason>" before sleeping and clears
  it when the attempt answers or the retries are exhausted.
- i18n ui.retry_note in en/de/pt_BR; README says the wait is visible.
- test_agent: the note callback must have seen "retrying in" on the recovery
  case.

make check: all tests passed.
2026-11-17 18:14:31 +00:00
lotherk 0f46c22a58 model picker, steer feedback, tolerant SSE with retries, junction headers
- /model in the curses chat opens a picker: Up/Down, typing filters by
  provider/model, Enter takes the selector, Esc cancels. The list comes from
  the backend (sp_engine_models -> sp_provider_choices), not from a text
  scrape; the socket has a `models` command, so --attach gets the same picker,
  and the switch is still the ordinary "/model <selector>" input.
- steering: Enter during a turn now says so twice - a "steering queued: ..."
  row in the transcript and "Ns steering queued (n) steer>" in the input line
  until the step boundary picks it up; a rejected steer is an error entry.
- input lag: typing during a turn is echoed immediately (the input line is
  redrawn per key, not at the next 100 ms frame), and the history is only
  repainted when its generation changed, so a streaming turn no longer
  repaints the whole transcript on every clock tick.
- sidebar: the first line of every widget is bold, like its heading, so a
  plugin block has a title instead of a wall of small print.
- junction plugin: keeps every response header from /mcp, the status route and
  /v1/models; the widget shows the X-Junction-* routing stats, /junction lists
  all headers per source. It reads the status aliases (/status, /v1/status,
  /queue, /v1/queue) and remembers the one that answered, parses queue,
  endpoint p95/exhausted counts, and counts the models (/v1/models, probed on
  its own slower interval because it goes upstream).
- SSE: blank lines no longer abort a pretty-printed object, a truncated tail
  is dropped instead of failing the turn ("incomplete data line" is gone), and
  a [DONE] with a fragment clears it.
- retries: a request that fails before anything streamed (connection, missing
  status, 5xx) is tried three more times, 5 s apart; 4xx is not retried, and
  after the first chunk the error is reported instead of printing the answer
  twice. Ctrl-C ends a wait at once; SPLINTER_RETRY_WAIT_MS overrides the wait.
- tests: test_sse (split object across events, truncated tail), test_agent
  (four 500s = four requests; two 500s then an answer), test_engine and
  test_protocol (models list), test_junction (headers, aliases, models),
  test_ui (/model picker), test_focus (status keys).

make check: all tests passed.
2026-11-17 11:46:11 +00:00
lotherkandClaude Sonnet 5.5 0b7a91e3b7 config blocks, pools, -m/--model-list, waiting out usage limits
Config: { } blocks (core, telegram, provider, pool, exit) translated to the flat
reader with source line numbers; flat form still loads; delegate/plugin limits
raised. Pools: failover/balance, used by delegation (tag-safe), by -m and for
the conversation when its provider hits a limit. -m SEL picks a pool, provider,
provider/model or model name; --model-list lists them with served models.
Usage limits: the agent finds the reset and waits (UI: Ctrl-C stops, /resume
goes on; on_limit=fail turns it off).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 22:12:26 +00:00
Konrad 10e59f23ac splinter 0.1.0: loop, registry, session, transports, tests
Rebuilt from scratch after the previous attempt left no code behind: what
exists here is what compiles and what the tests prove, and nothing else is
claimed.

What is in it:
- a turn loop that refuses an over-budget request before sending it, reports
  unknown tools instead of guessing, and honours authorization classes
  (read runs, mutate/destructive ask unless --autonomous);
- a registry that is authoritative - the model names a tool, the registry
  decides whether it exists;
- an append-only JSONL session (O_APPEND, fsync per record), where a crash can
  only truncate the tail and the tail is skipped, not repaired;
- two transports: a deterministic mock (queue of replies, last request kept)
  and HTTP via curl(1) with the request body in a temp file;
- two builtins that exist to prove the classes: echo (read) and run
  (destructive, reports its exit status as an observation).

Five test binaries, no external framework, no network: mock driver covers the
answer path, a tool round, an unknown tool, a denial, autonomy, a failing tool,
the step limit, the byte budget (asserting that nothing was sent) and a
non-2xx reply.

The wire format is splinter's own line protocol (user/observe out,
answer/tool in); provider adapters translate. That is why the loop is testable
without a model, and why no vendor JSON is parsed in the core.
2026-11-07 08:06:34 +00:00