Commit Graph
10 Commits
Author SHA1 Message Date
adm f74d53e446 memory: per-session semantic memory (strata-memory crate, Qdrant Edge + BGE-M3)
remember/recall/forget agent tools, one-way opt-in latch with embedder gate, fail-open Store-authoritative design, keyword fallback, model-id rebuild, GUI toggle + i18n; docs updated; split-debuginfo=unpacked
2026-11-30 11:37:48 +01:00
adm 6898cdf113 agent: loop-repetition guard, earlier notepad warn, tighter silence watchdog
Feedback from the framework agent (agent-feedback/2026-11-30-proposte.md),
evaluated against the real code; outcome in agent-feedback/2026-11-30-esito.md.

- agent/mod.rs: detect REPEAT_LIMIT=3 consecutive identical tool-call batches and
  stop with agent_loop_detected before burning MAX_ITERS; the repeating request
  is dropped before persistence so no dangling tool_call turn is left. New test
  loop_detects_repeated_tool_calls; step-limit test now varies its commands.
- notepad: SOFT_WARN_CHARS 6000 -> 4000 (warn at half the ceiling; consolidation
  itself costs an extra model turn).
- config/supervisor: silence watchdog default 600s -> 120s (already configurable
  via silence_timeout_secs); a long output gap is almost always a hang.

Rejected: bash -lc -> bash -c (the login shell preserves the user environment).
Deferred: token-based window cut (heavy; KV-cache interaction; to design with the
new engine). Suite: 204 passed / 3 ignored, clippy/fmt clean.
2026-11-30 02:30:00 +01:00
adm 0d335b808c agent: wire MCP connectors into the loop (rmcp v3, Initialize lifecycle)
- src/mcp: streamable-HTTP client (rmcp v3.12) negotiating Initialize +
  LATEST_WITH_INITIALIZE; namespaced mcp__{connector}__{tool} surface, write
  badges from ToolAnnotations, persisted discovery (tools_json) so the agent
  tool declarations stay byte-stable for KV-cache reuse.
- store: mcp_connectors catalog + tools_json column (idempotent migration) and
  set_mcp_tools; per-session per-tool allowlist (SessionSettings.mcp_enabled).
- agent: execute_mcp routes namespaced calls, gated on the session allowlist
  before any network call; Bearer token comes from the DB catalog, never echoed.
- api/sessions: build the MCP surface into Ambient + the agent tool declarations
  on both the turn and prewarm paths (identical rebuild keeps the prefix stable).
- api/mcp + GUI: connector CRUD, tool-discovery picker, per-session enable.
- examples/mcp_probe: read-only CLI discovery spike.

Live-verified: 22 gmail tools discovered, gmail_labels returned 25 labels, and a
full model-driven GUI turn (7 enabled tools) with a 9197-token RESUME cache hit.
2026-11-30 02:29:55 +01:00
adm 2f5b263d4e agent: share_file tool + containment-checked download endpoint
The agent can hand the user a same-origin download link for a file on its
filesystem (outbound complement to uploads). share_file(path, name?) returns a
Markdown link the GUI renders as a download chip.

Safety is containment, not trust: a shared path must canonicalize inside the
session personal folder or the shared uploads/ dir (.. and symlink escapes
refused), regular files only, 64 MiB cap. GET /api/sessions/{id}/download
re-validates independently (author != verifier), forces attachment +
application/octet-stream + nosniff, bare 400 out-of-bounds, 404 unknown session.

TOOL_USE seed migration appends the share_file manual without clobbering
user-edited rows. README documents the tool surface, endpoint and boundary;
Status refreshed to the verified 191 passed / 3 ignored.
2026-11-29 01:23:18 +01:00
adm 09542e05a1 audit: tool_call_id replay, CoT dup guard, notepad/shell/sqlite/detok hardening (BUG-04/05/06/07/11/16, SEC-11) 2026-11-27 18:13:18 +01:00
adm 0ce84581a4 Add context management: notepad, sliding window, cache reuse, windowed GUI
Per-session notepad: agent-curated labelled entries via the notepad tool
(set/remove/clear), injected as a pinned <NOTEPAD> section above DIALOG,
char-budgeted with a consolidate ceiling, exposed in a read-only GUI panel.

Sliding DIALOG window (src/window.rs): retains recent messages by count in
two tiers (MAIN_AREA=40 + BUFFER=10), append-only while the buffer fills so
the prompt prefix stays byte-stable for KV reuse, then stepped hysteresis
eviction snapping to user-turn boundaries (never splits a tool exchange).
window_start persisted per session; full history never deleted.

Engine prefix-cache reuse: leave DIALOG open (a moving </DIALOG> closer broke
the engine prompt_ckpt_prefix every user turn, forcing full re-prefill);
surface usage.cached_tokens as a GUI badge; fix the PerfMeter prefill gauge to
gauge over non-cached tokens; add a static sliding-window marker after the
opener so the model knows older turns are omitted.

Stats clarity: distinguish the current inference context (last_prompt_tokens,
new "Contesto attuale" card) from the cumulative lifetime token total
(relabeled "Token cumulativi ... su tutti i turni"); /api/stats carries both.

Windowed browser transcript: GET /api/sessions/{id}/messages returns only the
retained window (SQL-filtered by window_start, never loads the full history)
plus the total count, wrapped as {messages, window_start, total}; the GUI shows
a banner noting older turns are preserved server-side. Full-chat export deferred.

Settings: the session scope re-reads the persisted instance fresh from the store
(like the general scope already did), fixing a stale-cache display that looked
like the session System Prompt was not being kept.

Docs (README) refreshed; 158 tests + 3 ignored green, clippy and fmt clean.
2026-11-26 03:12:23 +01:00
adm fb9b822f58 Drop per-tool host/container sandbox; schedule semantic vector memory
Safety is an environment boundary of the whole process, not a per-tool
sandbox: run strata-ctl itself in a container/VM/isolated machine for
stronger protection. The planned "isolated mode" (Docker-MCP ShellRunner)
is cancelled; ShellRunner stays only as a test/alternate-runner seam.
README + agent/shell/sessions comments updated accordingly.

Add a Roadmap section with the next headline feature: a Qoder-style
semantic vector memory (embed + index conversation chunks, notes,
uploads, learned facts; similarity retrieval injected per turn plus
remember/search tools). Recommended shape: embedded sqlite-vec in the
existing SQLite store behind the Store trait + a small local multilingual
embedder; carries over to the planned ArangoDB vector indexes. Scheduled,
not implemented.
2026-11-25 18:08:04 +01:00
adm 5117ecad7a feat(agent): tools on by default, personal-folder cwd, streamed final answer
- GUI: agent mode (tools) enabled by default; the 🤖 toggle still turns it off.
- shell_exec defaults to the session's personal folder (~/.strata-ctl/sessions/<name>)
  when the model omits cwd, so the agent's home base matches its identity reminder;
  full host access retained (cd / absolute paths). run_loop gains a LoopContext
  (runner/store/default_cwd/max_iters/progress) to stay within the arg-count lint.
- Agent final answer now streams live: the model step uses service.stream, emits
  AgentEvent::Delta (reasoning + content) while generating, and returns the
  accumulated response for tool detection + persistence. The GUI renders a live
  assistant bubble (thinking auto-opens, folds when the answer starts) instead of
  receiving the whole final answer at once.
- Verified live: 76 delta events over 10.75s, pwd -> sessions/<name>, correct answer.
- 122 tests + 2 ignored; clippy/fmt clean.
2026-11-25 17:01:06 +01:00
adm 0568b92e06 Session settings copy-on-create + immutable friendly names
- SessionSettings instance per session (system_prompt, notes, sampling), snapshotted from global defaults at creation (copy-on-create); editing a session affects only it, editing globals affects only future sessions. Global defaults template stored in DB, seeded from config; GET/PUT /api/settings/defaults.

- Framework-assigned evocative names (word list, src/name.rs) replace the auto-title (removed). Name editable only before the first interaction, then locked (name_locked); PATCH rejects post-lock rename. Session notes carry the user-defined purpose.

- Idempotent migration adds settings_json/name_locked and backfills old sessions; build_request uses the session's own settings snapshot. 112 tests green, clippy/fmt clean; verified live (migration, name lock, settings isolation).
2026-11-25 15:44:52 +01:00
adm 8979201139 Add GUI agent mode: the model acts via a universal shell_exec tool
- agent:🐚 native shell_exec (bash -lc, cwd, timeout, 64 KiB output cap)
  behind a ShellRunner seam — base/host mode now; an isolated Docker-MCP runner
  plugs in later without touching the loop. OpenAI function declaration included.
- agent::run_loop: bounded model<->tool orchestration, generic over the model
  step so it is unit-testable without the engine. Persists the full trajectory
  (assistant tool-call turns + role:tool results + final answer) and emits
  tool_call / tool_result / final / error progress events.
- api::sessions: POST .../chat with agent:true drives the loop and streams the
  events as SSE; the GUI shows commands + output inline (observability, no gate).
- store: messages gains tool_call_id; an idempotent migration adds the column to
  pre-existing databases (CREATE TABLE IF NOT EXISTS does not alter them).
- web: robot agent toggle, tool-call/output blocks, history rendering of tool
  turns; inline favicon to silence the favicon 404.

Validated LIVE on engine 0.1.67: the model called shell_exec('uname -a'), the
host executed it, and the model reported the output; trajectory persisted; GUI
verified by browser (toggle, tool block, output, final answer). 106 tests +
2 ignored green, clippy/fmt clean. Isolated mode (user-provided Docker container)
is the next step.
2026-11-25 02:06:45 +01:00