8000 feat: support developer and fallback message roles by sheepbox8646 · Pull Request #27 · felinics/twilight · GitHub
[go: up one dir, main page]

Skip to content

feat: support developer and fallback message roles - #27

Merged
sheepbox8646 merged 1 commit into
mainfrom
codex/support-developer-message-roles
Jul 24, 2026
Merged

sheepbox8646 merged 1 commit into
mainfrom
codex/support-developer-message-roles

Conversation

@sheepbox8646
Copy link
Copy Markdown
Member

Summary

  • add developer as a first-class SDK message role with constructor and JSON validation
  • distinguish stable root instructions from system messages placed in the message timeline
  • add a shared compatibility layer for provider-aware role fallback, XML-safe system wrapping, and tool-exchange adjacency validation
  • preserve native system/developer roles in OpenAI Responses and OpenAI Chat Completions
  • add conservative fallbacks for Anthropic Messages, Gemini, Codex, and GitHub Copilot, with capability overrides where the endpoint contract can vary
  • update API/provider references for the new role and fallback behavior

Why

Runtime changes and other application instructions may occur after a conversation has started. Previously, some providers hoisted, dropped, or silently ignored these system messages, and the SDK had no semantic developer role. This made message ordering provider-dependent and could produce invalid requests when an instruction interrupted a tool-call/result exchange.

Developer impact

Callers can now use sdk.DeveloperMessage(...) and place sdk.SystemMessage(...) at the intended point in history. Providers serialize native roles when supported and otherwise apply deterministic user-role fallbacks without mutating caller messages.

Validation

  • go test -short -count=1 ./...
  • mise run test-race
  • mise run lint
  • mise run build
  • mise run vet
  • git diff --check

@sheepbox8646
sheepbox8646 marked this pull request as ready for review July 21, 2026 16:14
@sheepbox8646
sheepbox8646 merged commit c980301 into main Jul 24, 2026
3 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

0