Skip to content

docs: document the full sys__* reserved-variable surface (issue #37) - #50

Open
zoharbabin wants to merge 3 commits into
mainfrom
issue-37-reserved-var-docs
Open

docs: document the full sys__* reserved-variable surface (issue #37)#50
zoharbabin wants to merge 3 commits into
mainfrom
issue-37-reserved-var-docs

Conversation

@zoharbabin

@zoharbabin zoharbabin commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixed post-audit: audit-pr50-clean (independent, context-free subagent) found both notes above originally documented PR #48's and PR #49's capabilities as already shipped. Hedged in the file and here to reflect that neither PR is merged yet.

  • Corrects an over-broad claim I initially drafted about which reserved names the SDK's request_vars pre-flight guard rejects — verified against src/management/conversations.js's RESERVED_VARS (only 5 of the 8 names are guarded client-side today) rather than assuming parity across all 8.

Why this doesn't duplicate PR #49's table

PR #49 (not yet merged) adds its own reserved-variable table scoped to previewPrompt()'s client-side simulation. This PR's table is the canonical, live-behavior reference (not simulation-scoped) and lives in a different section (right after Converse, not inside "Preview a Prompt"). Since PR #49 isn't merged into this branch's base, I can't edit its content directly — flagging for the human reviewer merging both: once PR #49 lands, its own table should either link to this canonical one instead of repeating it, or be trimmed to only the simulation-specific caveats (_meta, draftPrompts, etc.), to avoid two tables describing the same 8 variables.

Deviations from the harnessed-build plan

Test plan

  • node tools/check-docs.mjs — all 12 doc-gate suites pass (secrets, GFM hygiene, cross-doc links, preview/loading annotation, etc.)
  • node scripts/harness/run.mjs — all 3 gates pass (npm run verify, semgrep SAST, npm run docs:gate)
  • Manually verified every SECURITY.md/issue/PR cross-reference and anchor slug resolves

🤖 Generated with Claude Code

This satisfies issue #37's documentation scope; left for the human reviewer to close manually after merge review.

Live testing confirms 3 undocumented reserved template variables beyond
the 5 already documented: sys__ks (raw session token — credential-exposure
risk if referenced in a prompt that gets echoed or logged), sys__is_new_thread,
and sys__user_obj.* (first_name/last_name/title/company/gender/email).

Adds a canonical "Reserved Template Variables" table covering all 8 names
in one place, with an explicit security warning on sys__ks, and a dated
note tracking the silent turn-failure behavior on sys__user_obj.* (backend
issue, not fixable from the SDK) with previewPrompt()'s pre-shipping
warning (issue #45 / PR #49) as the mitigation available today. Also notes
sys__user_id can now be bound via Sessions.createConversationToken({userId})
(issue #36 / PR #48).

Closes #37.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 22, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Tightened the sys__ks credential-leak sentence for clarity during the
adversarial self-review pass on PR #50 (issue #37).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
audit-pr50-clean found this doc overclaiming that sys__user_id binding
(PR #48) and previewPrompt()'s reserved_user_attr_unresolved warning
(PR #49) already work today. Both PRs are unmerged. Hedge both claims
so a developer reading this before those land doesn't rely on
behavior that doesn't exist yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zoharbabin

Copy link
Copy Markdown
Contributor Author

Metadata fix: removed a literal "Closes #37" from the PR body. This PR only satisfies issue #37's documentation scope — the backend fix and previewPrompt() hardening (PR #49) are separate, unmerged work — so issue #37 should stay open on merge, not auto-close. Left for the human reviewer to close manually once all of #37's success criteria are actually met.

@zoharbabin

Copy link
Copy Markdown
Contributor Author

Independent audit: audit-pr50-clean

A fresh, context-free subagent re-derived every claim in this PR against the repo directly, not from the PR description.

Verified independently (not just re-read):

Real defect found and fixed: the PR body (and the underlying commit message) framed the new table as covering "8 known reserved variables (the 5 already documented plus 3 newly confirmed live)." I forked a subagent to grep every markdown doc on main (README, GETTING-STARTED, SDK_CONSTITUTION, SECURITY, API-REFERENCE, all of docs/*.md) for these 5 variable names — zero prior mentions anywhere. None of the 8 had any user-facing documentation before this PR; the "5 already documented" framing overstated how much of this was already exposed to API consumers, when at most those 5 were named in source-level JSDoc (RESERVED_VARS/SYS_VARS), never in a doc a developer would actually read. Fixed via gh pr edit 50 --body-file, rewording the Summary's first bullet to state precisely what existed before (source JSDoc naming only, no doc table) versus what's new (the first user-facing documentation of all 8, plus 3 that aren't enforced anywhere in the SDK yet). Re-verified closingIssuesReferences is still empty after the edit.

Gate results:

  • node scripts/harness/run.mjsPASS (3/3: npm run verify, semgrep SAST, npm run docs:gate)
  • node tools/check-docs.mjsPASS (12/12 suites, 28/28 tests, 0 failures)

No other defects found — no GFM issues, no broken cross-references, no invented variables or wrong behavior claims beyond the one fixed above.

🤖 Generated with Claude Code

@zoharbabin

Copy link
Copy Markdown
Contributor Author

Live verification: remaining reserved-var claims — all confirmed

This PR's body already noted 3/8 vars (sys__ks, sys__is_new_thread, sys__user_obj.*) were live-tested and the other 5 were only source-verified. Ran a live check against the real backend covering all 8, using throwaway agents (provisioned and deleted in the same run).

Setup: intellects.setPrompts(configId, [], ks, {baseDirective}) to inject each {{var}} into a live base_directive, then conversations.send() on fresh/continued threads, cleanup via agents.delete/avatars.delete/intellects.delete.

Var Live result
sys__thread_id Echoed value == the real threadId returned by send().
sys__message_id Non-empty, changes every turn (turn 1 ≠ turn 2 on the same thread).
sys__user_id Resolves to empty — matches the doc's note that this is pending PR #48/issue #36.
sys__user_message Exact match to the text sent, on two separate turns.
sys__is_new_thread True on turn 1 of a new thread, False on turn 2 of the same thread.
sys__ks Resolves to a non-empty value — checked presence-only ({{sys__ks}} fed into a model instruction that must never echo it back), consistent with the security warning in this PR's doc addition.
secrets.<NAME> A throwaway secret set via intellects.secrets.set() resolved to its exact configured value when referenced as {{secrets.LIVE_TEST_SECRET}}.
sys__user_obj.first_name Reproduced the documented silent turn failure live: send() returned an empty string with no thread created, no thrown error — matches the "Known issue, dated 2026-08-22" callout in this PR's doc exactly.

One caveat worth recording: an early pass on secrets/sys__ks got canned refusals from the model ("I'm not able to process token verification requests...") — that was the model's own safety alignment reacting to test wording that looked like a secret-exfiltration probe (PING-THREE, "token verification"), not a resolution failure. Re-running with benign wording and one fresh thread per var eliminated it. Not a doc issue, just a note in case anyone else reproduces this and mistakes it for a resolution bug.

No inaccuracies found — every row in the Reserved Template Variables table is accurate as written. No doc changes needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants