From 207b0123a1b472c618bd8a733a1a79cd63ce8590 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Mon, 23 Nov 2026 14:09:38 +0100 Subject: [PATCH] fix(sdk-go): sync a directory to a router its stamp was not written for Agent.Sync trusted a matching .agent_sync stamp whichever router wrote it, so a folder synced to a local router and then to the hosted one sent nothing the second time. A matching stamp is now trusted only when the stored config's sync_hash is the same hash, as the JavaScript SDK does. --- .claude/skills/sdk/SKILL.md | 5 +++++ CHANGELOG.md | 4 ++++ sdks/go/agents/agent_test.go | 38 ++++++++++++++++++++++++++++++++++++ sdks/go/agents/config.go | 9 ++++++--- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/.claude/skills/sdk/SKILL.md b/.claude/skills/sdk/SKILL.md index bf802c6c63..90fe79812f 100644 --- a/.claude/skills/sdk/SKILL.md +++ b/.claude/skills/sdk/SKILL.md @@ -167,6 +167,11 @@ In .agent_sync store the sync status: This setup prevents duplicate syncs when they nothing changed. +The stamp says what was last sent, not where. Trust a matching stamp only when the stored config's +`sync_hash` is that hash too, so a directory synced to a local router and then pointed at a hosted +one (or another app) is synced there, not skipped. JavaScript and Go do this. Python +(`plugins/stream`), .NET, Ruby, Rust and PHP need to check theirs. + ## SDK updates Each SDK has an `.sdk_update_log` file naming the spec and this skill it was last updated against, as git blob ids: diff --git a/CHANGELOG.md b/CHANGELOG.md index 84bb3cb5f9..0913b531f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -843,6 +843,10 @@ A folder whose `agent.yaml` names a `plugins` list now fails to load with `plugi ## Bug Fixes +### The Go SDK syncs an agent's directory to a router it was never synced to + +`Agent.Sync` skipped a directory whose `.agent_sync` stamp matched it, whichever router the stamp came from, so a directory synced to a local router and then to the hosted one (`go run ./configure` with another `STREAM_ACCELERATION_URL`) answered the hosted router's old config and sent nothing. A matching stamp is now trusted only when the stored config's `sync_hash` is the same hash, as the JavaScript SDK does. + ### A hosted tool call in a group channel names the person who wrote In a channel an agent config answers through `chat_channels`, a call of a tool your backend hosts (a dispatch worker) named no user, so a backend acting for "the user who asked" (`tools.ToolCallContextFrom(ctx).User.ID`) got an empty id and had to refuse. Each call now names the writer of the message its turn answers, by user id and name: Anya's turn names Anya, and Ben's next one Ben, whether the config answers every message or only its mentions. A session opened with a user's token still names that user. diff --git a/sdks/go/agents/agent_test.go b/sdks/go/agents/agent_test.go index 26af722e5e..28e374d8bf 100644 --- a/sdks/go/agents/agent_test.go +++ b/sdks/go/agents/agent_test.go @@ -200,6 +200,7 @@ func newBackend(t *testing.T) *backend { stored := acceleration.AgentConfig{ Id: "config-" + request.Name, Name: request.Name, Instructions: request.Instructions, Subagent: request.Subagent, Llm: request.Llm, Tags: request.Tags, + SyncHash: &request.Hash, CreatedAt: time.Now(), UpdatedAt: time.Now(), } if !router.ignoresUI { @@ -2232,6 +2233,43 @@ func TestSyncFailsWhenConnectionsCannotBeListed(t *testing.T) { // The router does nothing for a hash it already stored (acceleration/internal/api/sync.go:180), // so the sync that finds the connection has to send another one. +func TestAnUnchangedDirectoryIsSyncedToARouterItWasNeverSyncedTo(t *testing.T) { + // Synced to a local router first, then pointed at the hosted one: the stamp the first + // sync left matches the directory, but the second router keeps nothing of it. + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nllm: openai/gpt-5.6\n") + local, hosted := newBackend(t), newBackend(t) + if _, err := agentOn(t, local, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + hosted.mu.Lock() + hosted.configs = []acceleration.AgentConfig{{Id: "config-concierge", Name: "concierge", CreatedAt: time.Now(), UpdatedAt: time.Now()}} + hosted.mu.Unlock() + + stored, err := agentOn(t, hosted, Options{Dir: root}).Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + + hosted.mu.Lock() + synced := len(hosted.syncs) + hosted.mu.Unlock() + if synced != 1 { + t.Fatalf("the router that never had the directory got %d syncs", synced) + } + if stored.Llm == nil || *stored.Llm != "openai/gpt-5.6" { + t.Errorf("the sync answered the router's old config: %+v", stored) + } + if _, err := agentOn(t, hosted, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + hosted.mu.Lock() + defer hosted.mu.Unlock() + if len(hosted.syncs) != 1 { + t.Errorf("an unchanged directory the router has was sent again: %d syncs", len(hosted.syncs)) + } +} + func TestASyncThatLeftAConnectorOutAddsItOnceTheConnectionExists(t *testing.T) { root := filepath.Join(t.TempDir(), "concierge") write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: company\n") diff --git a/sdks/go/agents/config.go b/sdks/go/agents/config.go index b4a276e41b..9088e9fec7 100644 --- a/sdks/go/agents/config.go +++ b/sdks/go/agents/config.go @@ -97,9 +97,12 @@ func (a *Agent) syncFolder(ctx context.Context, client *acceleration.ClientWithR if err != nil { return nil, err } - // A router older than ui_instructions takes the sync and drops them, which the stamp - // cannot tell, so a config missing the UI the stamp covers is synced again. - if stored != nil && (folder.UIInstructions == "" || deref(stored.UiInstructions) != "") { + // The stamp says what this directory last sent, not where: a router that never got it, + // such as a hosted one after a local sync, keeps another sync_hash and is synced. A + // router older than ui_instructions takes the sync and drops them, which the stamp + // cannot tell either, so a config missing the UI the stamp covers is synced again. + if stored != nil && deref(stored.SyncHash) == hash && + (folder.UIInstructions == "" || deref(stored.UiInstructions) != "") { return stored, nil } }