Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(agent): the invented-links label stops waiting for a success that never comes

purplee3f68457890f
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index ce8d3d94..39ef5c1e 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -1311,7 +1311,17 @@ export function useAgentChat() {
// steer to really search or retract; if it insists, the text stands
// (it is the model's answer, G14-2) and the bubble gets a labelled
// notice via unbackedLinks instead.
- if (anyToolSucceeded && turnContent.trim()) {
+ //
+ // The notice is NOT gated on a prior success: the Z36 counter-check
+ // (2026-08-22, persona run) watched Hermes-3-3B write its tool
+ // calls as prose, so no call ever really ran, and the invented
+ // links stood unmarked because the old anyToolSucceeded gate never
+ // armed. On an agent turn any link no tool returned is unverified
+ // by definition, so the label always tells the truth. Only the
+ // corrective STEER stays gated on a real success (the original Z36
+ // trigger), so a run that never used tools is not sent into an
+ // extra round.
+ if (turnContent.trim()) {
const shownToModel = agentMessages
.map((m) => {
const c = (m as { content?: unknown }).content
@@ -1326,7 +1336,7 @@ export function useAgentChat() {
.join('\n')
const invented = findUnbackedLinks(turnContent, shownToModel)
if (invented.length > 0) {
- if (!linksSteered) {
+ if (anyToolSucceeded && !linksSteered) {
linksSteered = true
log.info('agent.unbacked_links_steer', { count: invented.length, links: invented })
agentMessages.push({ role: 'assistant', content: turnContent })
diff --git a/src/lib/__tests__/unbacked-links.test.ts b/src/lib/__tests__/unbacked-links.test.ts
index e2f23957..e75c57b0 100644
--- a/src/lib/__tests__/unbacked-links.test.ts
+++ b/src/lib/__tests__/unbacked-links.test.ts
@@ -141,12 +141,17 @@ describe('wiring (source guards)', () => {
expect(agentSrc).toContain('unbackedLinksSteer(invented)')
})
- it('the guard only arms after a real success, the Z36 trigger', () => {
+ it('the notice runs on every final turn; the persona run proved a prose-only model never arms a success gate', () => {
+ // Z36 counter-check 2026-08-22: Hermes-3-3B wrote its tool calls as
+ // prose, no call ever ran, and invented links stood unmarked behind the
+ // old `anyToolSucceeded &&` gate. The label must not depend on a success.
expect(agentSrc).toContain('anyToolSucceeded = true')
- expect(agentSrc).toContain('if (anyToolSucceeded && turnContent.trim())')
+ expect(agentSrc).not.toContain('if (anyToolSucceeded && turnContent.trim())')
+ expect(agentSrc).toContain('if (turnContent.trim())')
})
- it('the steer fires once, then the message is flagged instead of looped', () => {
+ it('only the corrective steer stays gated on a real success, fires once, then the message is flagged', () => {
+ expect(agentSrc).toContain('if (anyToolSucceeded && !linksSteered)')
expect(agentSrc).toContain('linksSteered = true')
expect(agentSrc).toContain('updateMessageUnbackedLinks(convId!, assistantMessage.id, invented)')
})