Skip to content

feat: add opt-in Attention context and browser tools - #164

Merged
AndrewKirkovski merged 20 commits into
masterfrom
codex/attention-context
Oct 7, 2026
Merged

AndrewKirkovski merged 20 commits into
masterfrom
codex/attention-context

Conversation

@AndrewKirkovski

@AndrewKirkovski AndrewKirkovski commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Adds optional Attention support so an agent can answer questions such as "what am I pointing at?" or "find the Save button" from current browser evidence. Add wippy.agent.traits:attention to enable the tools. Live browser operations also require a compatible Session module and Web Host.

  • Agent: Adds nine read tools, automatic-context control, and highlight, confirmation, selection and capture tools. Semantic search and CSS search are separate; CSS stays within one named document or shadow root. Results retain canonical identity and ancestry, with an 8 KiB limit. The trait limits reads to one per batch and four attempts per user turn. The tool caller supplies browser authority only to the permitted calls.
  • LLM: Validates context by kind and version, then renders semantic context and authorized images as model input. Observed page content is treated as untrusted data. Technical context remains outside visible conversation text.
  • Relay: Forwards attention_context_enabled through the existing session-open flow.
  • Facade: Exposes the optional Attention configuration to the Host. Test fixtures load the intended local modules; Windows adapters follow their Makefiles.

Automatic context is off by default. Capture requires user approval and prepares a removable file for a later Send. Message delivery retains the existing request correlation and receipt.

V1 tools are selected through agent declarations and traits. An agent using wippy.agent.tools:* also receives Attention tools through wildcard expansion. Strict isolation for wildcard agents, current page URL/path and recursive route-owner reporting are deferred to V2.

Validation: all required Framework CI checks pass. With runner 0.3.45a, Agent 401, LLM 1,609, Relay 19 and Facade 77 tests pass, along with their lint checks. Four focused Attention browser cases pass. The ordinary-chat smoke also passes uploads, agent/model switching, Stop recovery and history reload.

Release LLM 0.5.5, Agent 0.5.3 and Relay 0.3.16 before Sessions 0.6.7. Publish Facade later, after Host 1.0.61 CDN deployment and its consumer smoke gates.

Checkpoint of the reviewed Attention V1 agent work, committed as is so
the review fixes that follow are separate, readable commits.

- Explicit attention_* read tools that project Host replies into the
  compact wippy.attention.model.v1 result.
- wippy.agent.traits:attention with its before_execute read guard and
  the private attention_read_receipt tool.
- Tool caller grants Attention runtime authority per call and strips
  inherited runtime fields from tool and session context.
- ATTENTION.md documents the tools, result format and read limits.
string.find and process.unlisten return two values. Passed straight into
test.not_nil, test.is_nil or test.is_true, the second value lands in the
message argument and fails the type check. Parentheses keep only the
first value. wippy lint --level error now reports no issues.
The read guard replaced a refused call's arguments with
{reason, original_registry_id, invalid}. Session persists those
arguments as the assistant's own function call, so the model lost what
it actually sent.

- The guard now keeps call.arguments and passes the refusal as
  context.attention_refusal, merged with any existing tool context.
  Tool context survives validate() and reaches the execution context.
- attention_read_receipt reads the refusal with ctx.get and ignores its
  arguments. Its input_schema accepts any object.
- The receipt result still carries invalid, so repair budget counting
  from history is unchanged.
- Tests assert unchanged arguments and the context refusal, and the
  caller test runs the real receipt tool with the execution context,
  including invalid-call repair budget counting.
attention_inspect accepted any operation and arguments and returned the
raw Host reply. It was not in the Attention trait, but any agent could
list it and get read authority outside the explicit read tools and
their limits.

- Remove its registry entry, its runtime authority in the tool caller
  and its handler and 32 KiB raw-result path in ui_action_tool.
- attention_read.is_read still recognizes the ID so stored history can
  be interpreted; the guard turns any new call into a refusal receipt.
- Process tests now use attention_get_tree and attention_find_semantic.
  The byte-limit test checks the 8 KiB compact projection instead of
  the removed raw bound. New tests cover the missing registry entry,
  the missing authority and the guard refusal.
- ATTENTION.md says the tool was removed and what replaces it.
ui_action_test_broker has meta type test-helper. The module's wippy.yaml
excludes only type test and scope dev, so the broker shipped with
wippy/agent.

Mark it scope: dev, the convention used in llm and views. The test app
loads src/agent from source and does not apply the publish excludes,
so the broker-backed process tests still find it.

Verified with wippy publish --dry-run (pack only): 49.4 KB before,
48.1 KB with scope: dev, and 48.1 KB for a control that changed the
broker to type test instead. Agent tests 344/344, lint clean.
The trait prompt opened with "Return only the requested fields." It
goes into the system prompt of every agent with the Attention trait and
was not limited to Attention answers, so it could conflict with the
agent's own answer instructions.

The sentence now reads "When answering from Attention tool results,
report only the fields the user asked about." The rest of the paragraph
is unchanged.
@AndrewKirkovski AndrewKirkovski self-assigned this Oct 7, 2026
@AndrewKirkovski
AndrewKirkovski merged commit 3cdba7e into master Oct 7, 2026
24 checks passed
@AndrewKirkovski
AndrewKirkovski deleted the codex/attention-context branch October 7, 2026 11:42
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