Skip to content

fix(canvas): send model when generating CONTEXT.md with agent#3389

Merged
benjackwhite merged 1 commit into
mainfrom
posthog-code/fix-context-md-generation-model
Jul 13, 2026
Merged

fix(canvas): send model when generating CONTEXT.md with agent#3389
benjackwhite merged 1 commit into
mainfrom
posthog-code/fix-context-md-generation-model

Conversation

@benjackwhite

Copy link
Copy Markdown
Contributor

Problem

Using Generate with agent to create a channel's CONTEXT.md in PostHog Code desktop fails immediately with a validation error and generation never starts:

{"type":"validation_error","code":"invalid_input","detail":"This field is required when selecting a cloud runtime.","attr":"model"}

Why: this flow was reported from the desktop app as broken — clicking the button to generate a CONTEXT.md returns the error above instead of kicking off a run.

The generate flow starts a cloud run but never picks a model (the agent chooses its repo at runtime, so no model picker is shown). The cloud-create path in the task-creation saga defaults the runtime adapter to claude but leaves the model unset, and the task-run bootstrap API requires a runtime adapter and model together — a runtime adapter without a model is rejected.

Changes

Pin the default gateway model in useGenerateContext so the adapter/model pair the API requires is always complete, matching the adapter the saga already defaults to. This mirrors how the other programmatic cloud-run entry points (inbox, workstream actions) resolve a model before starting a run.

How did you test this?

  • pnpm --filter @posthog/ui typecheck — passes
  • biome check on the changed file — clean
  • Traced the request path end to end against the backend serializer that raises the error to confirm the missing model is the cause.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog from a Slack thread

The "Generate with agent" flow for a channel's CONTEXT.md starts a cloud run
without a model. The cloud-create path defaults the runtime adapter to "claude"
but leaves the model unset, and the task-run bootstrap API rejects a runtime
adapter without a paired model ("This field is required when selecting a cloud
runtime."), so generation never starts.

Pin the default gateway model in the generate flow, matching the adapter the
saga defaults to, so the adapter/model pair the API requires is always complete.

Generated-By: PostHog Code
Task-Id: c292e951-0bde-4d16-8fb2-c18104829a09
@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 777114e.

@benjackwhite benjackwhite marked this pull request as ready for review July 13, 2026 12:32
@benjackwhite benjackwhite merged commit 59f538b into main Jul 13, 2026
27 checks passed
@benjackwhite benjackwhite deleted the posthog-code/fix-context-md-generation-model branch July 13, 2026 12:32
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(canvas): send model when generating ..." | Re-trigger Greptile

// rejects one without the other. Since this flow lets the agent pick
// its repo at runtime, it never surfaces a model picker, so pin the
// default gateway model here to match the adapter the saga defaults to.
model: DEFAULT_GATEWAY_MODEL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Pinned Model Skips Gateway Resolution

When the gateway does not advertise claude-opus-4-8 for a user, org, or region, this flow still sends that fixed model instead of falling back through the existing model resolver. The generate-context run can then fail validation or startup even though the request now includes a model field.

// rejects one without the other. Since this flow lets the agent pick
// its repo at runtime, it never surfaces a model picker, so pin the
// default gateway model here to match the adapter the saga defaults to.
model: DEFAULT_GATEWAY_MODEL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Model Sent Without Adapter

This call now sends model: DEFAULT_GATEWAY_MODEL, but it still does not send the matching adapter. If the cloud API enforces the adapter/model pair the inline comment describes, the default cloud generate path can serialize runtime_adapter: null with a Claude model and be rejected before generation starts.

charlesvien pushed a commit to ricardo-leiva/code that referenced this pull request Jul 13, 2026
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