Skip to content

Conversation

@gor-st
Copy link
Contributor

@gor-st gor-st commented Dec 14, 2025

Fixes #740

Summary

  • Add a new session_id output that exposes the Claude Code session ID
  • This allows other workflows or Claude Code instances to resume the conversation using --resume <session_id>

Changes

  • Add parseAndSetSessionId() function to extract session_id from the system.init message in execution output
  • Add session_id output to both action.yml and base-action/action.yml
  • Add comprehensive tests for the new functionality

Usage

This enables powerful multi-step workflows where Claude Code can be invoked, intermediate GitHub Actions steps can run, and then the conversation can be resumed with full context preserved:

jobs:
  claude-workflow:
    runs-on: ubuntu-latest
    steps:
      # Step 1: Initial Claude Code execution
      - uses: actions/checkout@v4

      - uses: anthropics/claude-code-action@v1
        id: claude-analyze
        with:
          prompt: "Analyze this codebase and identify what dependencies need to be checked"
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

      # Step 2: Intermediate steps - checkout additional repos, run tests, gather data
      - uses: actions/checkout@v4
        with:
          repository: my-org/shared-dependencies
          path: ./deps

      - name: Run dependency analysis
        id: deps
        run: |
          echo "dep_report=$(./deps/analyze.sh)" >> $GITHUB_OUTPUT

      - name: Fetch external API data
        run: |
          curl -s https://api.example.com/status > status.json

      # Step 3: Resume the Claude conversation with new context
      - uses: anthropics/claude-code-action@v1
        with:
          prompt: |
            I've gathered the dependency report: ${{ steps.deps.outputs.dep_report }}.
            I also fetched the API status (see status.json).
            Please continue your analysis with this new information.
          claude_args: "--resume ${{ steps.claude-analyze.outputs.session_id }}"
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

This pattern is useful for:

  • Multi-repo analysis: Check out additional repositories and let Claude analyze them in context
  • External data integration: Fetch data from APIs, databases, or other services mid-conversation
  • Staged execution: Run tests or builds between Claude interactions
  • Human-in-the-loop: Allow manual approval steps before continuing automation

Test plan

  • Added unit tests for parseAndSetSessionId() function
  • Tests pass locally (bun test structured-output.test.ts - 13 tests pass)
  • TypeScript typecheck passes
  • Integration test with actual Claude Code execution

🤖 Generated with Claude Code

Add a new `session_id` output that exposes the Claude Code session ID,
allowing other workflows or Claude Code instances to resume the
conversation using `--resume <session_id>`.

Changes:
- Add parseAndSetSessionId() function to extract session_id from
  the system.init message in execution output
- Add session_id output to both action.yml and base-action/action.yml
- Add comprehensive tests for the new functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@gor-st
Copy link
Contributor Author

gor-st commented Dec 14, 2025

Hi @ashwin-ant,

I'd love to get your review and suggestions on this PR when you have a chance.

This adds a session_id output to the action, enabling workflows to resume Claude conversations after intermediate steps (like checking out additional repos, running tests, or fetching external data). The use cases are detailed in #740.

Let me know if you have any feedback or if there's anything I should change. Thanks!

@ashwin-ant
Copy link
Collaborator

Thanks!

@ashwin-ant ashwin-ant merged commit 67bf059 into anthropics:main Dec 15, 2025
4 of 20 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.

Feature Request: Expose session_id output for conversation resumption

2 participants