Four latency/ergonomics changes from the voice-gateway diagnosis:
1. Per-skill humanize override. A skill's own recorded config
(data/skills/<cat>/<name>/config.json -> {"humanize": bool}) now wins over
the per-platform and global defaults, so an already-speakable result
(time.now) can skip the rewrite. The gateway resolves the skill ref from the
result summary; `_finish_run` now emits `category.name: ok — …` (matching the
assessment summary) so the ref is available. Missing store/config/key and
test doubles degrade to the existing platform/global behavior.
2. Example voice endpointing: vad.silence_ms 1000 -> 500 (config.example.json).
3. Confident softmax winners skip their confirm guard. New
navigation.softmax_bypass_tau (default 0.5): a category winner at/above it
skips confirm_category_fit (trace `category_scope_bypassed`); a leaf winner
at/above it is handed to dispatch and skips confirm_skill_fit (trace
`intent_bypass`). Below the threshold the two-stage confirm is unchanged.
Assumption tested first on the decision log: 28/28 category and 28/28 leaf
winners >= 0.5 agreed with their guard.
4. Engine-throughput investigation saved to AGENTS.md "Later / open questions"
(routing/assessment compute dominates; profile the engine, not the audio).
Tests updated for the bypass threshold and added for the skill-level humanize
override and bypass paths. Full suite: 486 passed, 1 skipped.
Add trace boundaries and timings so the last-word -> first-audio latency can
be split by section:
- voice_transport: emit `voice_speech_end` (the last VAD-speech frame, i.e. the
true "last word"), `voice_speak_start`, `voice_tts_synth` (Piper duration +
audio length), and `voice_playback_start` (the instant the first reply
samples reach the device).
- trace: `TraceLog.append` accepts an explicit `ts` so an event records when it
happened, not when it was written.
- gateway/voice: trace `gateway_reply_dequeued` at the outbound pump.
- gateway/service: trace `humanize` (duration) and `gateway_reply_queued`; a
best-effort `_trace` helper tolerates test doubles with no trace log.
- log: persist the engine's per-decision `input_tokens`/`forward_seconds`/
`total_seconds` (already computed by the backend, previously discarded) into
the decision row's `extra.timing`.
scripts/voice-latency.py reads data/runs.jsonl and prints a per-interaction
breakdown (endpointing, STT, each SemIf guard, act/assess, humanize, TTS,
playback) plus aggregates.
Restore SemIfEngine.generate (autoregressive sampling from the loaded
llama.cpp context) and wrap it in provider.SemIfEngineClient, a non-HTTP
sibling of OpenAICompatClient with the same chat() surface. llm.SemIfLLMClient
keeps the LLMError contract so the scheduler's graceful draft_failed path and
the LLM bridge's 502 path are unchanged.
llm.provider now selects "semif" (the in-process decision model, no endpoint
or model needed), "opencode", or the default "ollama"; build_llm_client owns
the choice (build_scheduler delegates). Knobs live under llm.semif
(temperature 0 = greedy, max_tokens). bootstrap skips the ollama llm
warn/pull/probe when provider is semif.
Only the llm task supports it; codegen still needs a real code model.
Drop the urgency score and interrupt/preempt decisions: intake is now
idle -> dispatch, busy -> append to a bounded FIFO queue (RequestQueue).
The running process always finishes before the next queued request.
- queue.py: UrgencyQueue -> RequestQueue (deque, no weight/age/recency)
- scheduler.py: remove _priority_score, _interrupt_choice, urgency
constants, and the weight threaded through dispatch/authoring/requeue
- dashboard/static/gateway: drop weight + preempted handling
- tests + docs updated; flow-main.svg regenerated
The time seeds resolved "local" via datetime.now().astimezone(), which
returns the host's local zone. On a UTC host that is UTC, so "what time is
it?" answered in UTC. Decouple from the host: add a top-level `timezone`
config value (an IANA name; empty/unknown falls back to host local) and
resolve it through zoneinfo.
- timers.py: add resolve_timezone/local_now; TimerService takes a
timezone and formats due/fired times in it (Timer carries the tzinfo).
- scheduler.py: pass config["timezone"] into TimerService.
- seeds/time/{now,date,set_alarm}: use local_now(ctx.config).
- seeds/calendar/{create_event,next_event}: derive "now" the same way, so
a requested time is parsed in the user's zone.
- config.example.json: add `timezone` (empty = host local).
- tests: cover resolve_timezone, local_now, and zone-formatted timers.
- AGENTS.md: document the timezone value.
config.json (gitignored, per-machine) sets timezone to America/Chicago.
A query skill whose correct answer is "nothing" (no unread SimpleX
messages, no upcoming events) was marked failed by assess:outcome: the
option text framed the decision as literal goal-achievement, so the
model read "no messages" as the goal not being met. The run then
offered a repair and could rewrite a working skill.
Reword the assess:outcome options so a definitive "nothing found /
nothing to do" result counts as success and only an error, refusal, or
unresolved action is failure. Option ids and the question are unchanged,
so the decision-log schema, dream labels, and existing unit tests are
unaffected. Real-engine scores: empty inbox 0.145 -> 0.969, no events
0.132 -> 0.959, while unreachable/HTTP-401/discovery failures stay
failure.
Add an integration regression test and a CODEGEN.md note that an
explicit empty/none result is a successful run.
Move the actionability guard (confirm_non_action) to the top of navigate,
before category selection, instead of only firing when the category softmax
proposed response/create_category. A non-request now goes straight to the
closed response tree and never reaches the category softmax, and the category
softmax offers only real categories (the canned response tree is excluded), so
a request can never be canned and a non-request can never be routed into a
real category.
Reword the guard so vague/incomplete fragments ("what") count as non-action:
they previously matched none of the non_action cases and split the decision
(action 0.513 / non_action 0.487), so "what" authored a redundant
"unclear"/"clarify_intent" category. It now lands on the catchall
response.clarify.
Remove the now-dead CreateSkill-for-canned fallback and _canned_fallback.
Update AGENTS.md, the navigation unit tests, the tune_navigation eval set, and
add an integration test for the vague-fragment route.
The response category scope claimed to cover "inputs the agent cannot act
on", so an actionable request like "what is 255 * 12?" scored as in-scope
and landed in the response.unable canned refusal.
Add the actionability guard (confirm_non_action, phase
navigate:actionability, navigation.action_tau) which arbitrates the
response/create_category boundary whichever side the softmax proposed: the
closed response tree is now reached only when the input is not a request, so
a request no skill covers authors a skill instead. Reword the response scope,
drop the response.unable reply, and update tests/docs.
A 4B codegen model wrote a plausible body that called
urllib.request.urlopen and returned ActionResult without importing either.
The contract described imports in prose but never showed one (and the model
only ever sees CODEGEN.md, not the seeds it points at), and parse_skill_body
only compiled the AST — so the body was accepted and failed later at
materialize/run.
- CODEGEN.md: add a complete minimal example (imports first, then
INTEGRATION/CONTRACT/act), an explicit "import everything you use" note,
the correct DecisionRequest/Option import path, and a strengthened
acceptance criterion.
- codegen.py: parse_skill_body now rejects a body that references names it
never imports or binds, via a scope-aware symtable check (skips locals,
parameters, closures, builtins, and module dunders). The failure is a
ValueError, so the existing retry ladder fires with a corrective prompt.
- tests: parse-level coverage (missing imports, closures/locals/builtins,
module dunders, wrong-but-bound module paths) plus a pipeline test that an
import-less body fails authoring and leaves a restartable stub.
Extract build_codegen_client() from build_scheduler so the codegen client
(provider class plus auth/User-Agent) is constructed in one place, and use it
in test_generate_skill_body_codegen, which previously hardcoded a plain
CodegenClient and 403'd against the Console provider.
CODEGEN.md was strong on real integrations and config plumbing but silent on
the two things that make a skill turn a query into an output: reading
request.text for per-request arguments and returning the real result. Bodies
(and the old query-agnostic health-check example) were free to ignore the
request and return a generic string.
- add "Turning the request into arguments": read request.text, keep
per-request arguments out of CONTRACT, resolve targets with a SemIf
sub-decision, needs_input only for genuine ambiguity
- add "Producing the result (output)": action_log/new_state must carry the
fetched data or the service's real response, never a placeholder
- replace the worked example with a task-shaped body (extract tracking number
from the query, real HTTP lookup, real result) that passes the parser
- add import-time-safety and single-phase-resume rules + acceptance criteria
- mirror the two requirements into BODY_DIRECTIVES so first/retry/regen
prompts carry them, with tests asserting both
config.json is now per-machine USER config that no code writes: bootstrap
seeds it from config.example.json only when absent, then reads every
per-machine value from it. Flags override those values for the run only and
are never written back.
External refs (engine commit, GGUF url+sha256, HF tokenizer revision,
simplex-chat version/url+sha256) move out of config into a committed,
code-owned pins.json, so a git pull bump propagates on the next bootstrap
run instead of being frozen per machine. The agent reads engine
source/revision from pins.json and derives the GGUF path from engine.gguf_url
under .runtime/models/ (an explicit engine.gguf in config.json overrides it).
- config.example.json: drop all refs; ship the provisioned defaults
(codegen.timeout 3600, gateway/bridge enabled, dashboard 127.0.0.1)
- scripts/bootstrap.sh: seed config.json if absent, read pins from pins.json
and per-machine values from config.json, never write config.json; drop the
flags that only existed to populate config.json; US-delimit read fields so
empty values do not shift later fields
- semif_agent/cli.py: add load_pins / build_engine_config; load_config
hard-errors when config.json is missing
- tests/integration + README/AGENTS updated
Sampler parameters (temperature/top_p/presence_penalty/frequency_penalty)
now default to None and are omitted from the request payload when unset, so
the server's model/Modelfile default applies. The provider no longer guesses
values on the user's behalf; callers opt in via config or a per-chat override.
- provider.OpenAICompatClient / llm.LLMClient: default the four params to None
and only include them in the payload when set (max_tokens/reasoning_effort
already behaved this way).
- cli.build_scheduler: pass None when the config key is absent via _opt_float,
instead of hardcoded numeric fallbacks.
- codegen: remove ESCALATED_SAMPLER and its use on retries (body, elicitation,
testgen, regen). The retry ladder keeps the fresh short prompt but reuses the
configured/omitted sampler; appropriate values can't be known in advance for
arbitrary user models.
- console: no functional change; the hosted Console API now receives no sampler
params by default.
- Tests cover omit-by-default, send-when-configured, per-call override, and the
no-escalation retry.
- Docs: config.example.json comments, provider/llm/codegen/console docstrings,
AGENTS.md.
Elicitation now asks one question at a time: only one PendingQuestion is
live, and the next is posted only after the current is answered (an empty
answer is accepted) or skipped. Each question gets a fresh
codegen.elicitation.answer_timeout (default 30s) that resets on every answer
submit; a timeout stops the sequence. questions_timeout is now traced only on
a real timeout. Front ends need no change — they read pending_questions().
Add opt-in creation_approval: the single-slot llm draft worker blocks after
authoring a proposal and before anything is registered; approve/deny via the
REPL, dashboard (/api/approvals + UI), or a gateway chat reply (yes/no). One
prompt per creation request (a category approval covers its chained skill);
denial or timeout aborts creation. Off by default.
Tests updated for both; full stdlib suite passes (337).
Submitting from the dashboard cleared the input and then showed nothing until
the next poll, so a slow submit looked like a no-op. POST /api/submit now
returns the new request_id alongside status/detail (Scheduler.submit_request),
and the front end keeps a `pendingSubmit` entry: it immediately renders a
synthetic "submitted" node plus an in-flight spinner, then swaps to the real
run once its trace row appears (matching by request_id) and clears the pending
state. A run that has landed but has no decisions yet also gets the spinner
instead of an empty flow. Adds a test asserting the returned request_id matches
a trace run.
Also flip config.example.json codegen defaults to stream:true and
temperature 1 / top_p 0.95 / presence_penalty 0 / frequency_penalty 1.
Resolve the navigate() leaf conflict: keep the local two-stage navigation
refactor (descriptions, confirm_category_fit, create_skill removed from the
leaf softmax) and apply origin's compose_state intent on top.
origin/main (857ad1a) was not runnable as pushed:
- compose_state renamed its param to additional_context but its body still
read `current` (NameError) and _navigate_canned called it with a stray
`additional_context:` annotation (SyntaxError).
- the rename was not propagated to scheduler.py's two callers (TypeError).
Resolution:
- compose_state(request, additional_context=None) renders `({additional_context})`.
- canned + navigate leaf decisions pass
additional_context=f"all choices are within the {category} category".
- scheduler.py builds its state inline to keep the exact
`[current process: …]` wording for the interrupt/priority decisions.
Skills now have a single `act(ctx, request)` body phase. The free-string
`Prediction.text` handoff, the `Prediction` type, and the predict phase are
gone.
- Resolution is pipeline-owned: the tiered config merge (global -> category ->
skill) fills contract vars; the authoring-time SemIf search now searches the
whole cascade; unresolved vars pause pre-act (`pre_act`, renamed from
`pre_predict`) and are asked of the human one at a time.
- The data contract is a module-level `CONTRACT` constant in the body, parsed by
`parse_contract`; `contract.json` is a derived mirror. The separate
`generate_data_contract` codegen call is removed.
- Candidate selection stays in the body: a set of candidates (bridge endpoint,
direct API, hard-coded list) gets a SemIf query, and the decisions ride back on
`ActionResult.decisions` to be logged with the run outcome (phase `act`).
- `assess:outcome`/`assess:requeue` state carries the resolved inputs (secrets
redacted by name) so the decision sees the full query -> resolution -> action
path.
- Authoring validation enforces: compiles + `act`; `INTEGRATION` flat and valid;
`CONTRACT` flat str->str; every CONTRACT key actually read from `ctx.config`.
- Test-regen ladder narrowed to code/test (the contract rides in the code).
SKILL.md/TESTGEN.md rewritten; seeds (calendar.next_event, simplex.next_message,
simplex.connect_link) rewritten to act-only + CONTRACT; docs updated.
BREAKING: persisted bodies in data/skills/ must be regenerated.
The in-memory inbox is a receive buffer, not the daemon's read state, so
the bridge could not see messages that arrived while it was down. Query
/_get chats <userId> count=<n> with a ChatListQuery unread filter
(chatStats{unreadCount, minUnreadItemId} + chatItem.meta.itemStatus
rcvNew/rcvRead) and /_get chat @<id> count=<n> over the existing
corrId->Future path, and expose GET /unread and GET /history?contact=<id>.
Both are read-only (v7 has no mark-read command) and degrade like
/address: 503 not connected, 502 lookup failure, 400 without a contact.
The live /inbox buffer is unchanged.
The bridge only learned contacts from observed inbound senders, so /send
could not address a contact it had never received from. Query /_contacts
<userId> (active user from /user, cached) over the existing corrId->Future
path, merge into the inbox on (re)connect via an on_connected hook and on
demand (GET /contacts, send-resolution miss). Best-effort: a disconnected
daemon keeps the cached set.
Move new category/skill draft authoring off SemIfEngine.generate onto a
separate small OpenAI-compatible provider, deliberately distinct from
codegen. Extract the shared transport (SSE/budget/idle/degeneration) into
provider.OpenAICompatClient; LLMClient and CodegenClient subclass it with
their own endpoints, sampler defaults, and error types.
Draft authoring now runs on its own async single-slot worker: a create
request queues, the gate stays free, a category job chains into its skill
job, and the original request re-runs when the body lands. An unreachable
llm endpoint is graceful (draft_failed trace, user notified, no
re-dispatch); only SemIf availability is fatal. Elicitation is deferred on
every front end (REPL included) now that authoring is async.
There is no up-front handle/ignore filter any more. Every input is scored
and dispatched; inputs that are not tasks fall through navigation into the
closed response category of hardcoded canned lines (greeting/thanks/
acknowledge/farewell/affirm/unable + the catchall response.clarify). The
category is CANNED_CATEGORIES: navigation offers no create_skill there,
dispatch/restart refuse to author it, and the runner skips assessment and
repair for it (a canned line has no side effect to assess).
Removes _contains_request/build_gate_decision and the dropped path.
Real engine on the seed tree: genuine creates lead by 0.42-0.93 while the
weak-plurality cases ('any new messages?', 'unread messages', 'calendar
today', 'get invite link') lead the best existing skill by 0.14-0.34.
Set create_tau=0.5, create_margin=0.35 so those ambiguous reads fall back
to the existing skill; the send regression (0.87 margin) is unaffected.
The create branches share a softmax with the real options, so a weak
plurality win was enough to trigger authoring. Require P(create) to clear
navigation.create_tau and lead the best existing option by
navigation.create_margin; otherwise fall back to the best existing option
(the intent guard remains a second door) and trace create_suppressed.
An empty tree/category still short-circuits straight to create.
Bridge specifics (service, base-URL config var, auth header/token var,
config-var docs, endpoints with error shapes) now live in BridgeInfo and
render through describe_bridges(), which is injected into body, retry,
regen, elicitation, and testgen prompts. SKILL.md/TESTGEN.md carry only
the generic pattern.
- regen prompt regains the catalog (was a dangling reference)
- elicitation integration hint rides body/retry/regen as an advisory
- top-level simplex_bridge_token config var; bootstrap syncs it
- simplex seeds read the token and send X-Semif-Token when set
SemIf routing only sees option descriptions, but the leaf fallback said
'Suggest creating a new skill' (mechanism, not trigger), so a send request
had no verb match and fell through to the read skill that shared the word
'message'. Every send phrasing picked simplex.next_message; create_skill
scored ~0.03 and codegen was never reached.
- navigate: reword the create_skill fallback to the trigger ('No existing
skill performs this action') and make the criterion ask which skill
performs the requested action. Sends now route to create_skill at P~0.93.
- confirm_skill_fit: one action-vs-action SemIf guard (phase navigate:intent)
after routing; a mismatch authors a new leaf instead of silently running the
wrong skill. Wording tuned on the real model (no IM hint: it over-fires).
- gate: imperative tasks are actionable even with no matching skill, so a
casually phrased send is no longer dropped as 'no actionable request'.
- finish_run: a failure whose retry is refused by the reentry budget still
surfaces a repair offer.
Validated on jarvis: gate accepts all tasks/rejects all noise, sends route to
CreateSkill, reads still route to their skills. Dev: 265 passed; jarvis
non-codegen integration: 6 passed.
Assessment was an LLM generation step emitting prose. Move it to SemIf:
- assess:outcome (success/failure @ tau) and assess:requeue (complete/retry,
updated_request = request.text bounded by max_reentries) are logged decisions.
- Run summary is deterministic (category.skill + ok/failed + action_log/new_state).
- Fidelity gate is a real authoring:fidelity accept/reconsider decision plus
static integration findings; it only triggers a rewrite, never a diagnosis.
- Corrective regens receive the raw evidence bundle as-is (render_evidence),
never an LLM paraphrase.
- Every EngineUnavailable is fatal app-wide: Scheduler.fatal is recorded, the
worker stops, and the CLI prints 'decision engine not available' and exits
non-zero. Remove llm.assess/review_skill_body (keep _parse_json).
- Tests: ScriptedEngine double in tests/conftest.py for scheduling mechanics;
replace the review_skill_body integration test with a SemIf fidelity test;
add deterministic-summary and evidence-renderer unit tests.
Split messaging UX (invite links, read, send) out of the command gateway into a
new `semif_agent.bridges` layer. Each bridge is its own process (`cli bridge`)
against its own service daemon/profile; the SimpleX bridge owns a second
simplex-chat daemon and buffers every inbound DM, so a message sent to the
connect-link address shows up in `simplex.next_message`.
- new: bridges/{base,inbox,registry,simplex}.py + neutral semif_agent/simplex_ws.py
- gateway: delete bridge.py; drop address/observer/pull-mode from the command path
- codegen: inject the bridge catalog (describe_bridges) into body + elicitation prompts
- seeds: repoint simplex.next_message/connect_link to top-level `simplex_bridge_url`
- config/bootstrap: new top-level `bridges` block + `simplex_bridge_url`; render
semif-simplex-forward + semif-bridge units; gateway config loses bridge/inbox
- docs: AGENTS.md gateway isolation is non-negotiable
- cli.load_config anchors skill_seeds/skill_bodies/category_registry/log/trace
to the checkout root, so a fresh clone's committed seeds load from any cwd
(running outside the repo root had an empty tree -> codegen loop).
- `skills` (CLI + REPL) lists scheduler.tree, not a throwaway built-ins tree.
- SimpleX adapter reads the real /_show_address shape
(contactLink.connLinkContact), so simplex.connect_link returns the link
instead of reporting no address.
Add a reusable corrId->Future request path to SimplexAdapter so the daemon
can be queried off the event loop, expose it as GET /address on the local
messaging bridge (injected address_provider; 503 unwired, 502 on daemon
failure), and ship a simplex.connect_link seed that reports the bot's short
and full contact link honestly, creating it on first call.
The gateway now exposes a localhost stdlib HTTP API (bridge.py) that
buffers authorized inbound DMs and forwards outbound sends, so a skill
body never opens a WebSocket to the simplex-chat daemon. Endpoints:
GET /health, /contacts, /inbox (peek), /inbox/next (pop oldest unread),
POST /send (resolve id/display name onto the adapter's outbound queue).
GatewayService gains an observer hook and inbox.dispatch (pull-only mode).
Expose the capability to codegen (SKILL.md, BODY_DIRECTIVES, elicitation,
TESTGEN.md) and add the simplex.next_message seed (SemIf recipient
resolution) with its hermetic loopback test. Config: messaging_bridge_url
plus gateway.simplex.{inbox,bridge}; bootstrap keeps them in sync.
Inbound DMs were silently dropped: simplex-chat v7 tags received text as
{"type": "rcvMsgContent", "msgContent": {"type": "text", ...}}, but
_parse_chat_item required a flat {"type": "text", "text": ...}. Every
message returned None (no gateway_message/gateway_sent/denied ever fired) so
pepper got no reply.
- parse content.msgContent.text, tolerating the DB/Aeson constructor-keyed
nesting as well
- resolve the peer name from profile.displayName first; v7's contact
displayName is null and localDisplayName is collision-suffixed (pepper_1)
- update the synthetic fixture to the real wire shape and add regression tests
- set PYTHONUNBUFFERED=1 in the rendered gateway unit so journal logging is live
The v7 receivedContactRequest event exposes contactRequestId (and contactId_,
the underscore being the generated-API optional marker); /_accept takes the
request id. The adapter looked for contactRequest.contactId, found nothing, and
silently no-oped — so contact requests hung unaccepted. Prefer contactRequestId,
fall back to contactId for legacy events, and trace the accepted ids. Tests for
both shapes and the disabled case.