Skip to content

ACP session creation missing required cwd parameter causing "Improperly formed request" error - #253

Merged
jbrinkman merged 2 commits into
mainfrom
spec/issue-251-28856
Jul 15, 2026
Merged

ACP session creation missing required cwd parameter causing "Improperly formed request" error#253
jbrinkman merged 2 commits into
mainfrom
spec/issue-251-28856

Conversation

@jbrinkman

Copy link
Copy Markdown
Owner

Summary

Fixes the ACP session creation error in the planning tab by adding the required cwd (current working directory) parameter to NewSessionRequest calls.

Problem

When sending a prompt in the planning tab, ACP session creation fails with an "Improperly formed request" error because the NewSessionRequest is missing the required cwd parameter as specified in the ACP protocol.

Solution

Added cwd parameter to ACP connection configuration and ensured it's passed to all NewSession calls (both streaming and non-streaming).

Changes Made

Files Modified

  • internal/acp/types.go - Added Cwd string field to ConnectionConfig struct with validation
  • internal/acp/client.go - Updated both streaming and non-streaming NewSession calls to include Cwd parameter
  • internal/tui/planning_tab.go - Initialize working directory when creating ACP client in planning tab

Key Implementation Details

  • Added Cwd string field to ConnectionConfig struct with proper JSON tag
  • Updated DefaultConnectionConfig() to initialize Cwd with absolute path to current working directory
  • Enhanced ValidateConnectionConfig() to validate Cwd is non-empty and absolute path
  • Updated both NewSession calls (lines 320 and 407) in client.go to include Cwd: c.config.Cwd
  • Added debug logging for working directory operations
  • Planning tab now sets working directory using os.Getwd() with proper error handling

Testing

  • ✅ All formatting, linting, and build checks pass
  • ✅ All 9 acceptance criteria from the issue verified
  • ✅ No regression in existing ACP functionality
  • ✅ Debug logging confirms cwd parameter is properly set

Validation

Verified that the implementation addresses all acceptance criteria:

  1. ✅ Added Cwd field to ConnectionConfig
  2. ✅ Defaults to current working directory if not specified
  3. ✅ Updated streaming NewSession call to include Cwd
  4. ✅ Updated non-streaming NewSession call to include Cwd
  5. ✅ Uses working directory from connection config
  6. ✅ Initializes working directory in planning tab
  7. ✅ Uses os.Getwd() as specified
  8. ✅ Ensures cwd path is absolute before use
  9. ✅ Added debug logging for working directory

Closes #251

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jbrinkman, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec622920-d61e-41a0-b11c-7dd85ee49a1c

📥 Commits

Reviewing files that changed from the base of the PR and between 863e3ae and ec3f4aa.

📒 Files selected for processing (4)
  • .kiro-krew/specs/issue-251-acp-session-missing-cwd-parameter.md
  • internal/acp/client.go
  • internal/acp/types.go
  • internal/tui/planning_tab.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spec/issue-251-28856

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI 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.

Pull request overview

Fixes ACP protocol compliance for session creation by ensuring cwd (absolute working directory) is included in session/new requests, addressing the “Improperly formed request” failure in the planning tab.

Changes:

  • Added Cwd to ACP ConnectionConfig, with defaulting and validation to ensure it is non-empty and absolute.
  • Updated both streaming and non-streaming NewSession requests to include Cwd.
  • Initialized ACP client configuration in the planning tab to set/pass a working directory.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/tui/planning_tab.go Sets ACP client Cwd when creating the planner ACP client.
internal/acp/types.go Adds ConnectionConfig.Cwd, defaults it, and validates it as required + absolute.
internal/acp/client.go Passes Cwd into both NewSession call sites and logs it.
.kiro-krew/specs/issue-251-acp-session-missing-cwd-parameter.md Adds design specification documenting the fix and acceptance criteria.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +133 to +150
cwd, err := os.Getwd()
if err != nil {
logging.Warn("failed to get current working directory, using fallback", "tab_id", id, "error", err)
cwd = "."
}

// Ensure absolute path
if !filepath.IsAbs(cwd) {
if absCwd, err := filepath.Abs(cwd); err == nil {
cwd = absCwd
}
}

logging.Info("initializing ACP client with working directory", "tab_id", id, "cwd", cwd)

config := acp.DefaultConnectionConfig()
config.Agent = "planner"
config.Cwd = cwd
Comment thread internal/acp/types.go
Comment on lines +156 to +165
cwd, err := os.Getwd()
if err != nil {
cwd = "." // Fallback to current directory
}
// Convert to absolute path
if !filepath.IsAbs(cwd) {
if absCwd, err := filepath.Abs(cwd); err == nil {
cwd = absCwd
}
}
- Use os.TempDir() as absolute fallback when os.Getwd() fails
- Make absolute path conversion unconditional with safety fallback
- Change planning tab cwd logging from Info to Debug level

Addresses Copilot review feedback on PR #253:
- Prevents validation failures when working directory is unavailable
- Avoids exposing local paths in normal logs
- Ensures Connect() remains possible in edge cases

Signed-off-by: Joseph Brinkman <joe.brinkman@improving.com>
@jbrinkman
jbrinkman merged commit 4460c6f into main Jul 15, 2026
2 checks passed
@jbrinkman
jbrinkman deleted the spec/issue-251-28856 branch July 15, 2026 14:09
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.

ACP session creation missing required cwd parameter causing "Improperly formed request" error

2 participants