Skip to content

Commit cee109f

Browse files
committed
feat: expose input_tokens, output_tokens, cached_input_tokens as step outputs
Adds three new step outputs to codex-action: input-tokens, output-tokens, and cached-input-tokens. After codex exec completes, a new extract-token-outputs step reads the rollout JSONL written by the Codex CLI to $CODEX_HOME/sessions/, finds the last token_count event (cumulative totals), and surfaces the values as step outputs. Outputs are empty strings when token data is unavailable — non-breaking, existing workflows unaffected. Closes #65 Made-with: Cursor
1 parent 48c4212 commit cee109f

4 files changed

Lines changed: 647 additions & 359 deletions

File tree

action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ outputs:
101101
final-message:
102102
description: "Raw output emitted by `codex exec`."
103103
value: ${{ steps.run_codex.outputs['final-message'] }}
104+
input-tokens:
105+
description: "Total input tokens consumed by the Codex run (empty if unavailable)."
106+
value: ${{ steps.extract_tokens.outputs['input-tokens'] }}
107+
output-tokens:
108+
description: "Total output tokens consumed by the Codex run (empty if unavailable)."
109+
value: ${{ steps.extract_tokens.outputs['output-tokens'] }}
110+
cached-input-tokens:
111+
description: "Total cached input tokens consumed by the Codex run (empty if unavailable)."
112+
value: ${{ steps.extract_tokens.outputs['cached-input-tokens'] }}
104113
runs:
105114
using: "composite"
106115
steps:
@@ -349,3 +358,14 @@ runs:
349358
--effort "$CODEX_EFFORT" \
350359
--safety-strategy "$CODEX_SAFETY_STRATEGY" \
351360
--codex-user "$CODEX_USER"
361+
362+
- name: Extract token outputs
363+
id: extract_tokens
364+
if: ${{ inputs.prompt != '' || inputs['prompt-file'] != '' }}
365+
env:
366+
ACTION_PATH: ${{ github.action_path }}
367+
CODEX_HOME: ${{ steps.resolve_home.outputs.codex-home }}
368+
shell: bash
369+
run: |
370+
node "$ACTION_PATH/dist/main.js" extract-token-outputs \
371+
--codex-home "$CODEX_HOME"

0 commit comments

Comments
 (0)