Skip to content

feat(specialist): add exec metadata flags#104

Merged
anandh8x merged 2 commits into
mainfrom
feat/specialist-exec-metadata
Jun 7, 2026
Merged

feat(specialist): add exec metadata flags#104
anandh8x merged 2 commits into
mainfrom
feat/specialist-exec-metadata

Conversation

@anandh8x

@anandh8x anandh8x commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary:

  • adds specialist-oriented zero exec metadata flags: calling session/tool ids, tag, depth, session title, and init session id
  • propagates the metadata into agent.Options for later specialist runtime slices
  • lets --init-session-id preallocate a new exec session id and accepts debug as a stream-json output alias

Scope:

Tests:

  • GOCACHE=/tmp/zero-go-cache go test ./internal/cli ./internal/agent
  • GOCACHE=/tmp/zero-go-cache go test ./...
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added --calling-session-id, --calling-tool-use-id, --tag, --depth, --session-title, and --init-session-id to zero exec; session titles can be set via --session-title.
    • --output-format debug added as an alias for JSON streaming.
  • Documentation

    • Updated zero exec help text to document the new flags and aliases.
  • Bug Fixes / Validation

    • New validation for --depth (non-negative) and --init-session-id usage (only when creating/forking).
  • Tests

    • Added tests covering new flags, validations, and session initialization.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: 8e4ba1888dcc
Changed files (6): internal/agent/types.go, internal/cli/app.go, internal/cli/exec.go, internal/cli/exec_parse.go, internal/cli/exec_sessions.go, internal/cli/exec_test.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d78688c0-c872-40fc-a80f-20fca9af3f51

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7f7d5 and 8e4ba18.

📒 Files selected for processing (3)
  • internal/cli/exec.go
  • internal/cli/exec_parse.go
  • internal/cli/exec_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/cli/exec_test.go
  • internal/cli/exec.go
  • internal/cli/exec_parse.go

Walkthrough

The PR adds CLI flags and wiring so specialist/session metadata (--calling-session-id, --calling-tool-use-id, --tag, --depth, --session-title, --init-session-id) are parsed, validated, used for session creation/title, and passed through to agent execution with tests and updated help text.

Changes

Specialist Session Metadata Support

Layer / File(s) Summary
Agent options metadata contract
internal/agent/types.go
agent.Options struct is extended with CallingSessionID, CallingToolUseID, Tag, Depth, and SessionTitle fields to carry specialist context through execution.
CLI help text updates
internal/cli/app.go
zero exec help includes the debugstream-json alias and documents --calling-session-id, --calling-tool-use-id, --tag, --depth, --session-title, and --init-session-id.
Session initialization and title generation
internal/cli/exec_sessions.go
shouldUseExecSession also triggers on --init-session-id. execSessionTitle prefers a trimmed --session-title override or falls back to createSessionTitle(prompt).
Exec options and agent integration
internal/cli/exec.go
execOptions gains metadata/init fields; session prep uses initSessionID and execSessionTitle; agent.Run is passed the full metadata payload in agent.Options.
CLI flag parsing and validation
internal/cli/exec_parse.go
parseExecArgs parses new flags in both --flag value and --flag=value forms, adds parseExecDepth and requiredInlineFlagValue, enforces cross-flag constraints (e.g., --init-session-id incompatible with --resume), validates --init-session-id via sessions.ValidSessionID, and treats --output-format debug as the JSON stream alias.
Help documentation and test coverage
internal/cli/app.go, internal/cli/exec_test.go
Help assertions updated; tests added for parsing of metadata flags, invalid value handling (depth/tag/init-session-id), --init-session-id usage constraints, output-format alias, and an integration-style test asserting session creation/title/cwd under XDG_DATA_HOME.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • gnanam1990
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding specialist-oriented exec metadata flags (calling session/tool IDs, tag, depth, session title, init session ID) across multiple CLI and agent files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/specialist-exec-metadata

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/cli/exec.go (1)

167-170: ⚡ Quick win

Use one computed session title value across session prep and agent metadata.

Right now session creation uses execSessionTitle(...), while agent metadata uses raw options.sessionTitle. When no explicit title is provided, those diverge (session has generated title; agent metadata is empty).

Suggested fix
 	prompt, err := resolveExecPrompt(options, workspaceRoot, deps.stdin)
 	if err != nil {
 		return writeExecFormatUsageError(stdout, stderr, options.outputFormat, err.Error())
 	}
+	sessionTitle := execSessionTitle(options, prompt)

 	overrides := config.Overrides{}
@@
 	if shouldUseExecSession(options) {
 		preparedSession, err = sessions.PrepareExec(sessions.PrepareExecOptions{
 			SessionID:    options.initSessionID,
-			Title:        execSessionTitle(options, prompt),
+			Title:        sessionTitle,
 			Cwd:          workspaceRoot,
@@
 	result, err := agent.Run(context.Background(), agentPrompt, provider, agent.Options{
@@
-		SessionTitle:     options.sessionTitle,
+		SessionTitle:     sessionTitle,

Also applies to: 211-217

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/exec.go` around lines 167 - 170, Compute the session title once
and reuse it for both session preparation and agent metadata: call
execSessionTitle(...) once into a local variable (e.g., computedTitle) before
invoking sessions.PrepareExec and then pass that same computedTitle into
PrepareExecOptions.Title and wherever agent metadata currently reads
options.sessionTitle; update the other occurrence (the similar block around the
211-217 region) to use the same computedTitle so generated and explicit titles
never diverge.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cli/exec_parse.go`:
- Around line 374-377: The invalid-format error message returned by
parseExecOutputFormat omits the accepted "debug" alias; update the error text in
the default branch (where execOutputStreamJSON and "debug" are handled) to list
"debug" alongside text, json, and stream-json so the hint matches actual
accepted values (refer to parseExecOutputFormat, execOutputStreamJSON and the
"debug" case).

---

Nitpick comments:
In `@internal/cli/exec.go`:
- Around line 167-170: Compute the session title once and reuse it for both
session preparation and agent metadata: call execSessionTitle(...) once into a
local variable (e.g., computedTitle) before invoking sessions.PrepareExec and
then pass that same computedTitle into PrepareExecOptions.Title and wherever
agent metadata currently reads options.sessionTitle; update the other occurrence
(the similar block around the 211-217 region) to use the same computedTitle so
generated and explicit titles never diverge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3420cf-880e-4fea-81d5-f0cf66622ae1

📥 Commits

Reviewing files that changed from the base of the PR and between af6a0ef and 7f7f7d5.

📒 Files selected for processing (6)
  • internal/agent/types.go
  • internal/cli/app.go
  • internal/cli/exec.go
  • internal/cli/exec_parse.go
  • internal/cli/exec_sessions.go
  • internal/cli/exec_test.go

Comment thread internal/cli/exec_parse.go Outdated

@gnanam1990 gnanam1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — clean, approving with a couple of notes

Nice, focused PR — the flag parsing is consistent (both --flag value and --flag=value forms, shared requiredInlineFlagValue/nextFlagValue helpers), validation is solid (--depth rejects non-int/negative, --init-session-id validated via sessions.ValidSessionID, sensible conflict checks), execSessionTitle/shouldUseExecSession are correct, and it's well covered by TestParseExecSpecialistMetadataFlags / ...RejectsInvalidValues / TestRunExecUsesInitSessionIDAndSessionTitle. Build + go test ./internal/cli ./internal/agent green. Approving.

Non-blocking notes

  1. debug alias missing from the error hint (exec_parse.go:377, as CodeRabbit noted) — parseExecOutputFormat accepts debug but the invalid-format error still says "Expected text, json, or stream-json." One-word fix: add , or debug so the guidance matches behavior.

  2. ⚠️ agent.Options.Depth coordination — heads-up from working in the adjacent area: the upcoming sub-agent (task) runtime also introduces agent.Options.Depth with the same meaning ("sub-agent nesting level; child = Depth+1; refuse at/above maxTaskDepth"). This PR adds Depth (plus CallingSessionID/CallingToolUseID) as exec metadata. They're the same concept — worth syncing with whoever owns the task-runtime slice so you converge on one Depth field with agreed semantics, otherwise the second PR to land hits a duplicate-field/merge collision. Same spirit for the other calling-* metadata.

  3. Plumbed-but-not-yet-consumedCallingSessionID, CallingToolUseID, Tag, SessionTitle, Depth are set on agent.Options but nothing in internal/agent reads them yet (matches your "later slices" note). Fine as staging; just flagging so it's a conscious choice — ideally these land with their consumer (or keep the doc comment so they're not mistaken for dead fields).

None of these block — they're a one-liner + coordination. 👍

🤖 Verified review via Claude Code.

@anandh8x
anandh8x merged commit ae6c959 into main Jun 7, 2026
6 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the feat/specialist-exec-metadata branch June 28, 2026 08:27
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.

2 participants