You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d96803c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(plugin): expose agent operating rules and allow forgetting them (#32)
* feat(plugin): expose agent operating rules and allow forgetting them
Add sessionObserver.listLearnings/forgetLearning plus synapse_list_rules and synapse_forget_rule plugin tools, so users can see which rules an agent follows (and whether each is actually injected) and remove one by text.
* fix(plugin): align rule listing with real injection, harden rule writes
- Derive injected from the same selection used to build the prompt, so the flag cannot drift from behaviour.
- Serialise record and forget writes on a shared store; write via temp file + rename so a crash cannot leave half-written JSON.
- Count a removal only after the write lands, and count distinct rules once when a rule exists in both stores.
* fix(plugin): key injected rules by text and serialise the injection read
- Match the injected set by normalized lesson text: memory and the file can hold the same rule under different ids, which id-matching missed.
- Read the injection source through the mutation queue so a read cannot reload a rule a queued forget is still removing.
* fix(plugin): merge loaded rules into the injection cache instead of replacing it
A rule recorded while the cache-load read was pending was clobbered by the older file contents; merging (deduped by text) keeps both.
return`✅ Successfully recorded rule: "${args.lesson}". This knowledge is stored and will automatically guide future sessions.`
1515
1515
},
1516
1516
}),
1517
-
synapse_buddy_review: tool({
1517
+
synapse_list_rules: tool({
1518
+
description:
1519
+
"List the operating rules (learnings) this agent follows, showing where each is stored and whether it is actually injected into the system prompt. Use when the user asks what rules you are following, or to audit a behaviour such as a language preference.",
injected+" of "+rules.length+" recorded rule(s) are injected into this session (the most recent "+INJECTED_LEARNINGS_LIMIT+").",
1527
+
...rules.map(
1528
+
(r,i)=>
1529
+
(i+1)+
1530
+
". "+
1531
+
(r.injected ? "[injected]" : "[stored] ")+
1532
+
" "+
1533
+
r.lesson+
1534
+
" (source: "+
1535
+
r.source+
1536
+
", store: "+
1537
+
r.origin+
1538
+
", recorded: "+
1539
+
r.timestamp+
1540
+
")",
1541
+
),
1542
+
].join("\n")
1543
+
},
1544
+
}),
1545
+
synapse_forget_rule: tool({
1546
+
description:
1547
+
"Remove an operating rule (learning) by matching text, so the agent stops applying it. Use when the user asks to stop doing something previously recorded, e.g. 'stop greeting me in French'.",
1548
+
args: {
1549
+
lesson: tool.schema
1550
+
.string()
1551
+
.describe("Text identifying the rule to remove (case-insensitive substring match)."),
1552
+
},
1553
+
asyncexecute(args){
1554
+
constneedle=(args.lesson||"").trim()
1555
+
if(!needle)return"Please provide the rule text to remove."
? 'Removed '+removed+' rule(s) matching "'+needle+'". They will not be applied in future sessions.'
1559
+
: 'No rule matched "'+needle+'". Use synapse_list_rules to see the recorded rules.'
1560
+
},
1561
+
}),synapse_buddy_review: tool({
1518
1562
description:
1519
1563
"Run an instant, $0-cost on-premises code review using the Synapse Coder specialist. Checks code snippets or files for syntax errors, SQL injection, broken imports, and security defects.",
0 commit comments