Skip to content

Add initial branch and initial prompt to Session#1494

Open
gjkim42 wants to merge 1 commit into
mainfrom
session-spawner
Open

Add initial branch and initial prompt to Session#1494
gjkim42 wants to merge 1 commit into
mainfrom
session-spawner

Conversation

@gjkim42

@gjkim42 gjkim42 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds initialBranch and initialPrompt to the v1alpha2 Session API so an interactive Session can initialize from a selected Git branch and automatically begin with a prompt.

The controller uses initialBranch only during workspace initialization. The runtime reads initialPrompt from the immutable Session resource and records and submits it before becoming ready when the workspace has no conversation history. Retained workspace history prevents resubmission after a runtime restart; replacing an emptyDir-backed Pod starts a fresh conversation and submits the prompt again.

The web form and YAML API round-trip both fields. Generated CRDs, reference documentation, examples, and tests are updated with the API.

Which issue(s) this PR is related to:

Fixes #1477

Special notes for your reviewer:

Validation completed:

  • make update
  • make test
  • make verify
  • make test-integration
  • focused Kelos API review
  • dual independent code review

Does this PR introduce a user-facing change?

Sessions can select an initial Git branch and automatically submit an initial prompt when the conversation workspace has no retained history.

@github-actions github-actions Bot added kind/feature Categorizes issue or PR as related to a new feature needs-triage needs-priority needs-actor release-note labels Jul 15, 2026
@gjkim42
gjkim42 marked this pull request as ready for review July 15, 2026 12:58

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 15 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/sessionruntime/server.go Outdated
@gjkim42

gjkim42 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator Author

/kelos api-review

@kelos-bot

kelos-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

🤖 Kelos Task Status

Task kelos-api-reviewer-issue-comment-2018b90812eb has succeeded. ✅

@kelos-bot
kelos-bot Bot force-pushed the session-spawner branch from 5dce3c6 to a8c8fa4 Compare July 18, 2026 12:15
@kelos-bot

kelos-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

🤖 Kelos API Reviewer Agent @gjkim42

API Design Review

Verdict: REQUEST CHANGES
Scope: Adds optional Session.spec.branch and Session.spec.initialPrompt fields to v1alpha2, with cross-field and length validation, generated CRDs, documentation, and examples.

Findings

Idempotency and recovery

  • [P1] api/v1alpha2/session_types.go:61, docs/reference.md:265 - The new contract is "once per workspace," and the documentation explicitly says an emptyDir-backed replacement Pod submits the prompt again (docs/reference.md:267). This conflicts with Session: Support an initial prompt at creation #1477's requirement that the initial prompt not replay after Pod recovery and makes a creation-time action repeat after eviction or replacement. The journal check at internal/sessionruntime/server.go:88 is not durable for the default emptyDir workspace. Persist delivery state outside the ephemeral workspace, with defined success/failure and recovery semantics (for example through Session status/conditions), or otherwise make the per-Session no-replay guarantee durable before this field ships.

Naming and declarative semantics

  • [P1] api/v1alpha2/session_types.go:54 - spec.branch is consumed only during initial workspace setup; the controller intentionally skips branch setup after initialization (internal/controller/session_controller.go:802) while status.branch tracks the actual current branch. The spec value can therefore diverge by design and does not represent desired state. Because this field name will be permanent, rename it to initialBranch (and update the server, docs, and generated manifests) or define and reconcile branch as the current desired branch.

Documentation

  • [P2] docs/reference.md:199 - The reference says conversation history "including an optional initial prompt" is retained in the workspace rather than the Kubernetes API, but spec.initialPrompt itself is stored in the immutable Session object. Clarify that the original prompt remains in the Kubernetes API and that only the conversation journal/history is workspace-backed, so users understand its visibility and retention.

/kelos needs-input

@kelos-bot
kelos-bot Bot force-pushed the session-spawner branch from a8c8fa4 to aab948b Compare July 18, 2026 13:24
@kelos-bot kelos-bot Bot changed the title Add branch and initial prompt to Session Add initial branch and initial prompt to Session Jul 18, 2026
@kelos-bot
kelos-bot Bot force-pushed the session-spawner branch 2 times, most recently from ba0a13b to 2bea5fe Compare July 18, 2026 13:58
@kelos-bot
kelos-bot Bot force-pushed the session-spawner branch from 2bea5fe to 2e1f2a0 Compare July 18, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session: Support an initial prompt at creation

1 participant