Skip to content

feat(integrations): Add POST endpoint for coding agent launch #97983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: jenn/coding-agent-seer-autofix-state
Choose a base branch
from

Conversation

jennmueng
Copy link
Member

@jennmueng jennmueng commented Aug 18, 2025

  • Add POST method to OrganizationCodingAgentsEndpoint for launching coding agents
  • Support launching agents for multiple repositories from autofix solutions
  • Include branch name sanitization and stores coding agent state to Seer on trigger

Context

This PR completes the coding agent framework by adding the POST endpoint that enables launching coding agents from the Seer UI. The endpoint:

  1. Validates the integration and autofix state
  2. Extracts repositories from the autofix solution
  3. Generates appropriate prompts based on trigger source
  4. Launches coding agents for each repository
  5. Stores the agent state in Seer for tracking
  6. Handles errors gracefully and continues processing other repos

The endpoint supports both root_cause and solution trigger sources, and includes comprehensive error handling and logging.

Stacked on: #97986

Architecture

  • POST /api/0/organizations/{org}/integrations/coding-agents/
  • Feature flagged behind organizations:seer-coding-agent-integrations
  • Integrates with Seer API for prompt generation and state storage
  • Multi-repository support with graceful error handling

@jennmueng jennmueng requested review from a team as code owners August 18, 2025 08:07
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 18, 2025
"""Extract repository names from autofix state solution."""
repos = set()
solution_step = next(step for step in autofix_state.steps if step["key"] == "solution")

Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Missing Default in next() Call Causes Crash

The _extract_repos_from_solution method uses next() without a default value when searching for the "solution" step. If this step is absent from autofix_state.steps, a StopIteration exception is raised, causing the POST endpoint to crash.

Fix in Cursor Fix in Web

Comment on lines 264 to 240
solution_item["relevant_code_file"]
and solution_item["relevant_code_file"]["repo_name"]
):
repos.add(solution_item["relevant_code_file"]["repo_name"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential bug: Unsafe dictionary access on solution_item["relevant_code_file"] may cause a KeyError. Frontend types show this field is optional, but the backend doesn't handle its absence, risking a server crash.
  • Description: The code directly accesses solution_item["relevant_code_file"] within a loop. Evidence from corresponding frontend TypeScript types (AutofixSolutionTimelineEvent) indicates that the relevant_code_file field is optional. If the Seer API, which provides this data, returns a solution_item where this key is missing, the direct dictionary access will raise an unhandled KeyError. This will cause the API endpoint to crash and return a 500 error, preventing the extraction of repository information from the autofix state.

  • Suggested fix: Use the .get() method for safe dictionary access to prevent a KeyError when the relevant_code_file key is missing. The code should be changed to solution_item.get("relevant_code_file") and include a check for the result before attempting to access nested keys like repo_name.
    severity: 0.65, confidence: 0.9

Did we get this right? 👍 / 👎 to inform future reviews.

@jennmueng jennmueng marked this pull request as draft August 18, 2025 12:28
@jennmueng jennmueng force-pushed the jenn/coding-agent-framework-get-endpoint branch 2 times, most recently from b82a980 to cf6e830 Compare August 18, 2025 13:07
- Add POST method to OrganizationCodingAgentsEndpoint for launching coding agents
- Implement autofix state retrieval and coding agent prompt generation
- Support launching agents for multiple repositories from autofix solutions
- Add comprehensive validation and error handling
- Include branch name sanitization and Seer state storage
- Add extensive test coverage for POST functionality
- Update autofix utilities with coding agent state models and prompt functions

This completes the coding agent framework by adding the ability to trigger
coding agents from Seer UI with autofix context.
@jennmueng jennmueng force-pushed the jenn/coding-agent-framework-post-endpoint branch from a3594bd to 3c63d92 Compare August 18, 2025 15:16
@jennmueng jennmueng changed the base branch from jenn/coding-agent-framework-get-endpoint to jenn/coding-agent-seer-autofix-state August 18, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant