Skip to content

feat(canvas): give agents the learnings a repository accepted - #11

Merged
alliscode merged 3 commits into
mainfrom
bentho-learnings-from-agents
Oct 16, 2026
Merged

alliscode merged 3 commits into
mainfrom
bentho-learnings-from-agents

Conversation

@alliscode

@alliscode alliscode commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Agents working in a repository should have the guidance its administrators accepted in Hub, without someone repeating those decisions in every session. This change gives agents that context through an approved Hub connection, without sending the person's prompt to Hub.

What changes

When someone submits a prompt, the Replica plugin asks Hub for the repository's accepted learnings and adds them as session context. Hub checks the connection's consent and the person's cached repository read permission. The learning store records the recall as a use by that person.

sequenceDiagram
  actor Person
  participant CLI as Copilot CLI with the Replica plugin
  participant Hub
  participant Store as Repository's learning store
  Person->>CLI: Submit a prompt
  CLI->>Hub: Ask for accepted learnings, without the prompt
  Hub->>Store: Recall learnings as that person
  Store-->>Hub: Text, learning IDs, and content digests
  Note over Store: Record use by the person
  Hub-->>CLI: Return accepted learnings
  CLI->>CLI: Check the format and add session context
Loading

The connection approval page now explains that Copilot can add accepted learnings to prompts. Hub records consent only when someone approves the current disclosure. Existing connections and older approval forms still connect without learnings; those users must disconnect and connect again to enable them.

The new POST /api/canvas/learnings/recall endpoint returns the learning text, IDs, and content digests, which identify changes to the wording. The plugin accepts only the bounded format produced by replica-learning, including its safety guidance that learnings are data, not commands. The first successful response replaces earlier learning context, including after a restart or session resume. Later unchanged responses add nothing; changed or empty responses replace earlier guidance. Turning Learnings off explicitly clears it.

The hook uses an existing connection and saved Hub selection; submitting a prompt never starts pairing or Hub discovery. Token renewal happens in the background for a later prompt. Hub limits each connection to 30 recalls per minute and stops slow recalls early enough for the plugin's three-second deadline. Errors, invalid responses, and timeouts add no context and never fail the prompt; older responses cannot overwrite a newer one.

Copilot CLI 1.0.96 requires --experimental or /experimental on for extensions. Loading a repository's project copy in prompt mode (copilot -p) also requires GITHUB_COPILOT_PROMPT_MODE_EXTENSIONS=true. Its ACP server does not load these hooks, so ACP clients do not receive learnings through this plugin.

The live integration check uses an isolated local-mode Hub and synthetic data; GitHub-backed OAuth and cross-account authorization remain unverified by that check. Its off/restore case exercises Hub's learnings_off response, not disconnecting a real Copilot account.

@alliscode
alliscode requested review from a team and nshki as code owners October 15, 2026 21:12
Copilot AI max review requested due to automatic review settings October 15, 2026 21:12
@alliscode alliscode changed the title feat(canvas): give agents the learnings a repository accepted- #305 feat(canvas): give agents the learnings a repository accepted Oct 15, 2026

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.

🔵 Needs a closer look

Consent and prompt-context delivery cross security boundaries, and GitHub-backed cross-account authorization remains unverified.

2 open findings
What changed in this PR

Adds repository-approved learnings to Copilot sessions through existing Hub connections, without sending prompts to Hub.

Changes:

  • Adds consent-gated, rate-limited learning recall.
  • Registers a prompt hook with response validation and session-context replacement.
  • Updates approval disclosures, persistence, tests, and guides.
File Description
hub/​test/​integration/​canvas_pairings_test.rb Tests versioned consent and older approvals.
hub/​test/​integration/​canvas_learning_recall_test.rb Tests recall access, auditing, limits, and timeouts.
hub/​test/​fixtures/​files/​slow-replica-learning.mjs Simulates delayed recall and lingering output.
hub/​test/​fixtures/​files/​learning.txt Supplies accepted learning text.
hub/​docs/​security.md Documents recall request limits.
hub/​docs/​security-rate-limits.md Defines the per-connection recall budget.
hub/​docs/​prototype-canvas.md Documents recall delivery and validation.
hub/​docs/​learnings.md Explains agent access to accepted learnings.
hub/​docs/​authentication-and-repository-authorization.md Explains learning consent during approval.
hub/​db/​schema.rb Records consent fields and constraint.
hub/​db/​migrate/​20261013120000_add_learnings_consent_to_canvas_connections.rb Adds consent persistence.
hub/​config/​routes.rb Routes learning recall requests.
hub/​config/​locales/​canvas_pairings.en.yml Adds the learning disclosure.
hub/​app/​views/​canvas_pairings/​show.json.props Exposes the disclosure version.
hub/​app/​models/​canvas_pairing.rb Records consent and transfers it to grants.
hub/​app/​models/​canvas_grant.rb Updates schema annotations for consent.
hub/​app/​javascript/​pages/​canvas-pairings-page/​types.ts Types the disclosure version.
hub/​app/​javascript/​pages/​canvas-pairings-page/​stories.tsx Updates approval story data.
hub/​app/​javascript/​pages/​canvas-pairings-page/​index.tsx Submits the disclosure version.
hub/​app/​javascript/​pages/​canvas-pairings-page/​index.test.tsx Tests disclosure display and submission.
hub/​app/​controllers/​concerns/​security_rate_limiting.rb Adds the recall budget.
hub/​app/​controllers/​canvas_pairings_controller.rb Passes the submitted consent version.
hub/​app/​controllers/​canvas_api/​learning_recalls_controller.rb Serves consent-gated recall responses.
hub/​app/​controllers/​canvas_api/​base_controller.rb Makes permission freshness overridable.
.github/​extensions/​replica-prototype/​register-prototype-canvas/​index.test.mjs Tests prompt-hook registration and delivery.
.github/​extensions/​replica-prototype/​register-prototype-canvas/​index.mjs Registers the learning hook.
.github/​extensions/​replica-prototype/​recall-learnings/​index.test.mjs Tests validation and session delivery behavior.
.github/​extensions/​replica-prototype/​recall-learnings/​index.mjs Validates and replaces learning context.
.github/​extensions/​replica-prototype/​README.md Explains delivery and CLI requirements.
.github/​extensions/​replica-prototype/​hub-client/​index.mjs Adds recall requests and background renewal.

🧠 Review effort: Max


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hub/app/controllers/canvas_api/learning_recalls_controller.rb
Comment thread .github/extensions/replica-prototype/recall-learnings/index.mjs Outdated
alliscode and others added 2 commits October 15, 2026 15:20
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a0fec4de-471b-4b6e-8d1c-0317e17aea5a
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a0fec4de-471b-4b6e-8d1c-0317e17aea5a

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.

🔵 Needs a closer look

The consent and private-data delivery boundary needs human review because GitHub-backed cross-account authorization remains unverified.

0 open findings

2 resolved since last review

🧠 Review effort: Max

@nshki nshki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @alliscode! Appreciate you and @thegovind working on the learning loop features here. I believe this closes the core loop.

@alliscode
alliscode merged commit 7ddb584 into main Oct 16, 2026
27 checks passed
@alliscode
alliscode deleted the bentho-learnings-from-agents branch October 16, 2026 16:37
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.

3 participants