Skip to content

The assistant answers how-to questions for the person asking and searches the namespace and the docs together - #509

Merged
zlareb1 merged 4 commits into
mainfrom
feat/assistant-help-asker
Nov 10, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
feat/assistant-help-asker

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #488
Related: #498

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The assistant answers "how do I…" for the person asking: it knows the kind of credential they ask with and the role it has in the namespace, and answers how that role is raised from Loom's documentation. A question that does not plainly ask how to use Loom is searched in the namespace's memories and documents and in the docs together, so a fact the namespace holds is answered from the namespace.

Why

#488 and #498 gave the assistant Loom's documentation and checked [help:] citations. Two gaps remained.

  • The asker. An answer's token is viewer on one namespace, so the agent could not tell what the person may do. "Can I write here? How would I get that?" got a generic answer.
  • The instructions. On a qualification run against LibreChat v0.8.8 and claude-haiku-4-5, the agent:
    • answered questions about the person's own systems (a rate limit, a webhook retry count, a cache size) from Loom's own docs instead of the namespace;
    • cited the writing guide as a docs page;
    • wrote two sections in one citation;
    • called no tool at all when a role line it could read as an answer opened the question.

Design (docs/architecture/assistant.md, "The asker's context" and "The agent definition"):

  • The asker line. open_answer, once an answer is admitted (after the rate limits and the cost checks, so a refused request pays for nothing), works out one line in fixed words from the caller's own credential. The bridge adds it as the last line of the question it sends:
    Loom, for how-to answers only: this question comes with <credential>, whose role in this <place> is <role>.
    • credential: a sign-in session, then a delegated token (a creator is set; capped by its creator's grant), then a scoped token (ns_roles), else a token.
    • role: the highest of admin and writer the gate admits (through CachedGate, the cached grant maps the listings use) after the viewer check every answer passes, else viewer. It is unknown when a check is refused because a read it needed failed, and also when any other exception occurs, so the line never refuses an answer.
    • place: a personal collection or a collection is known from the name; a restricted namespace comes from directory().is_restricted_cached, which does no read; anything else is a namespace.
    • What the line leaves out: it carries no subject and no namespace name, so nothing the caller controls reaches it and no identity goes to the model provider through it.
    • Why last: on the first line it made the agent skip its tools on role-sounding questions (measured below). On the last line it is context.
    • What the instructions say: the line is Loom's only in that place, grants nothing, and decides no tool call. How a role is raised is answered from the documentation for that credential and place, and the namespace's admins come from grants.list.
    • Rejected alternatives:
      • A namespace.list_mine call returns every namespace of the asker's in the org, which widens one answer's reach.
      • A new asker op cannot see the caller's token from inside the answer.
      • Rules about how a role rises, written into the instructions, were wrong for scoped, delegated and collection cases in review. So the docs carry the rules, and the instructions point at them.
  • The instructions (agent definition version 7):
    • A question that does not plainly ask how to use Loom starts with memory_search, knowledge_search and help_search together. A fact the namespace holds is answered from the namespace, even when Loom has a setting of the same kind.
    • Every question about Loom itself starts with help_search, and is answered only from what the docs say.
    • Read the section with help_get before answering from it, at most two sections per answer.
    • Copy the breadcrumb exactly, one page and section per bracket, and cite [help:] only for pages the help tools returned.
    • Name an op or setting only as a tool returned it, in backticks.

Scope and risk

  • server/assistant/app/bridge.py: asker_line, _credential, _gate_role, _place, _with_asker, Ticket.asker. open_answer builds the line once an answer is admitted, and stream appends it, for the chat route and assistant.ask alike.
  • integrations/librechat/agent.yaml: the instructions and the version bump. docs/architecture/assistant.md: the asker's context and the agent definition.
  • Cost. An admitted answer makes up to two more gate checks through the cached grant maps. An sa: token with no grant there also reads its service-account row once, and a claim capped at a revoked grant has the gate read the inheriting creator's grant itself; both happen only after admission. A refused request makes none. A how-to answer averages about $0.05 at list price on claude-haiku-4-5.
  • Spoofing. A person who writes the same line only misleads their own answer: tools still read under the answer's viewer token, and the instructions treat only the last line as Loom's.

Compatibility, rollout and rollback

  • Wire: none. The line is part of the request LibreChat is sent, not of any Loom op.
  • Operator steps: none. The newest build writes agent definition 7 at boot.
  • Rolling upgrade: a bridge of an earlier build sends no line, and an answer that depends on the person's role then says it does not know it.
  • Rollback: an older build leaves definition 7 in place, and its bridge sends no line.

Tests

  • tests/unit/test_assistant_asker.py:
    • each kind of credential in its order of precedence;
    • through the real gate with only the grant reads faked: a flat viewer token whose subject holds a writer grant reads back writer, and a token delegated by a creator who holds viewer reads back viewer;
    • the role is the highest the gate admits, and unknown on an unverified refusal or a failing check;
    • each kind of place;
    • no subject or name in the line, even a subject holding a newline;
    • the line closes the question and leaves earlier turns as sent.
  • tests/unit/test_assistant_bridge.py: the chat route and assistant.ask send the question with the line last.
  • tests/unit/test_assistant_service.py: the definition digest is pinned to version 7.
  • Ran: make format, make lint and make typecheck, and the assistant, doc-link, public-copy and LibreChat unit tests (601 passed).
  • Measured on the qualification harness against LibreChat v0.8.8, my own server and ClickHouse, with claude-haiku-4-5. The per-use-case table is in the coverage PR that follows.
    • With the line first, two role- and tenancy-sounding cases called no tool. With it last, both called their tools and passed.
    • Starting with all three searches brought the document cases back to 6 of 7, from 3 of 7 with two searches.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. The design went through six adversarial architecture reviews to zero findings, and the instruction changes were measured on the qualification harness.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 3 commits November 10, 2026 22:00
…ches the namespace and the docs together

The bridge ends each question it sends LibreChat with one line in fixed words:
the kind of credential the caller asks with, the role the gate gives it in the
namespace, and the kind of namespace. The agent's instructions read it as
context for how-to answers only, start a question that does not plainly ask
how to use Loom with a memory, a document and a help search together, and
cite each docs section as [help:].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… an answer is admitted; the instructions ask for the role only when the answer needs it

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…; the asker test fakes only the reads it needs

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 force-pushed the feat/assistant-help-asker branch from 8853361 to 9783489 Compare November 10, 2026 22:00
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 4969767 into main Nov 10, 2026
44 of 46 checks passed
@zlareb1
zlareb1 deleted the feat/assistant-help-asker branch November 10, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant