Skip to content

Conversation

tingwai
Copy link
Collaborator

@tingwai tingwai commented Sep 19, 2025

Description

Artificially triggered a context length error to demonstrate error message and exit code:
image

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-general-review or @continue-detailed-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Headless CLI now surfaces errors as JSON on stdout and exits with code 1, making scripts reliable and detectable. Addresses CON-3966 by bubbling errors up instead of swallowing them.

  • New Features

    • Headless mode outputs {"status":"error","message": "..."} and exits with code 1.
    • Errors propagate from chat processing; non-headless still shows colored logs.
    • Validates missing models or LLM API and returns clear messages.
  • Refactors

    • Extracted helpers for streaming and headless output to reduce complexity.
    • Typed LLM API as BaseLlmApi and improved Sentry error context.
    • Ensured telemetry stops before gracefulExit and on normal completion.

@tingwai tingwai requested a review from a team as a code owner September 19, 2025 23:26
@tingwai tingwai requested review from Patrick-Erichsen and removed request for a team September 19, 2025 23:26
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 19, 2025
}
}

// Helper function to get streaming response based on compaction state
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lines 164-218 are not new, had to refactor out some code to satisfy eslint function complexity rule

Copy link

AI Code Review

AI review failed due to service initialization issues. Please check the Continue API key and configuration.

No specific line comments generated.


💡 To request a new detailed review, comment @continue-detailed-review

@tingwai tingwai force-pushed the tingwai/con-3966-headless-exit-code branch from ec2936c to 8ad3506 Compare September 20, 2025 00:01
@tingwai tingwai force-pushed the tingwai/con-3966-headless-exit-code branch from 8ad3506 to 783760d Compare September 20, 2025 00:14
Comment on lines +99 to +103
expect(result.exitCode).toBe(1);

// Should contain authentication error (not service initialization error)
expect(result.stderr).toContain("authentication_error");
expect(result.stderr).toContain("invalid x-api-key");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the config still succeeds in creating but now that we're surfacing errors test now exits with 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant