Skip to content

fix: prefix ao send messages with sender session#85

Merged
harshitsinghbhandari merged 3 commits into
mainfrom
feat/worker-orchestrator
Jun 2, 2026
Merged

fix: prefix ao send messages with sender session#85
harshitsinghbhandari merged 3 commits into
mainfrom
feat/worker-orchestrator

Conversation

@harshitsinghbhandari
Copy link
Copy Markdown
Collaborator

Summary

  • prefix ao send daemon messages with [from <AO_SESSION_ID>] when AO_SESSION_ID is non-blank
  • preserve existing behavior for blank sender IDs and preserve original message whitespace after validation
  • add send CLI coverage for prefixed and blank sender behavior

Tests

  • go test ./internal/cli
  • go test ./... (fails in backend/internal/terminal: zellij IPC socket path is too long in this environment)

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR adds two related features: (1) ao send now prefixes outgoing daemon messages with [from <AO_SESSION_ID>] when the env var is non-blank, preserving original message whitespace; (2) Spawn now injects role-appropriate system prompts — an orchestrator-role block for orchestrator sessions, and an active-orchestrator contact hint for worker sessions.

  • send.go: AO_SESSION_ID is trimmed and checked before prepending; blank/whitespace values are treated as absent, and the raw message text (including its own whitespace) is preserved verbatim after the prefix.
  • manager.go: buildSpawnPrompt is extracted before CreateSession, so a store error during orchestrator lookup fails cleanly without creating a half-baked session row; activeOrchestratorSessionID returns on the first live orchestrator match.
  • Tests: New CLI tests cover prefixed sender, whitespace-only sender (no-op), and existing whitespace-preservation; new manager tests verify orchestrator prompt injection, terminated-orchestrator exclusion, and the coordinator role prompt for orchestrators.

Confidence Score: 5/5

Safe to merge — the sender-prefix logic is a narrow, well-isolated env-var read, and the prompt-injection path fails cleanly before any session is persisted.

The send.go change is minimal: trim, check, prepend — no state mutations. The manager.go refactor is sound: buildSpawnPrompt runs before CreateSession, so a store error during orchestrator lookup leaves no orphaned session row. activeOrchestratorSessionID returns on the first live match, which is deterministic for the common case. All new code paths have direct test coverage.

No files require special attention.

Important Files Changed

Filename Overview
backend/internal/cli/send.go Adds AO_SESSION_ID-based sender prefix to outgoing messages; implementation is correct, whitespace handling is intentional and tested.
backend/internal/cli/send_test.go Adds three targeted test cases covering prefixed sender, blank/whitespace-only sender (no prefix), and whitespace preservation; all existing tests also patched with explicit AO_SESSION_ID=''.
backend/internal/session_manager/manager.go Extracts prompt assembly into buildSpawnPrompt; adds orchestrator role and worker coordination prompts with correct early-exit on store error before session creation.
backend/internal/session_manager/manager_test.go Adds three new manager tests covering active orchestrator contact injection, terminated orchestrator exclusion, and orchestrator coordinator prompt generation.

Reviews (2): Last reviewed commit: "fix(session): return first active orches..." | Re-trigger Greptile

Comment thread backend/internal/session_manager/manager.go
Comment thread backend/internal/session_manager/manager.go Outdated
@harshitsinghbhandari harshitsinghbhandari merged commit 9058017 into main Jun 2, 2026
0 of 7 checks passed
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