Add sessionId extraction and displayName() to KnownAgent#9
Open
impruthvi wants to merge 2 commits intoshipfastlabs:mainfrom
Open
Add sessionId extraction and displayName() to KnownAgent#9impruthvi wants to merge 2 commits intoshipfastlabs:mainfrom
impruthvi wants to merge 2 commits intoshipfastlabs:mainfrom
Conversation
- AgentResult gains optional `sessionId` property (non-breaking) - AgentDetector extracts CODEX_THREAD_ID, AMP_CURRENT_THREAD_ID, and CLAUDE_CODE_SESSION_ID from env vars per detected agent - KnownAgent gains displayName() returning human-readable agent names (e.g. "Claude Code", "GitHub Copilot", "Gemini CLI") - 19 new tests covering sessionId extraction and all displayName() cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two non-breaking additions to
AgentResultandKnownAgent:Session ID extraction
AgentResultgains an optionalsessionIdproperty.AgentDetectornow readssession/thread env vars per agent before returning:
CODEX_THREAD_ID→ CodexAMP_CURRENT_THREAD_ID→ AmpCLAUDE_CODE_SESSION_ID→ Claude (future-ready)All other agents return
null— fully backwards compatible.Display names
KnownAgent::displayName()returns a human-readable name for each agent:KnownAgent::Claude->displayName()→"Claude Code"KnownAgent::Copilot->displayName()→"GitHub Copilot"Useful for logging, UI, and response headers where the internal key (
claude,copilot) is too terse.Why
Downstream tooling (log formatters, observability layers) needs both a pretty name
and a session ID to produce useful output. Without session IDs, all Codex log lines
are indistinguishable across runs.
Changes
src/AgentResult.php— add?string $sessionId = nullsrc/AgentDetector.php— extract session IDs viamatchbefore returningsrc/KnownAgent.php— adddisplayName(): stringtests/AgentDetectorTest.php— 19 new tests (session ID + display names)README.md— updated usage examples and agents tableTesting
All 59 tests pass.