Skip to content

feat(drift): use adaptive sampling rate by default#229

Merged
jy-tan merged 4 commits intomainfrom
devin/1777429830-adaptive-sampling-default
Apr 29, 2026
Merged

feat(drift): use adaptive sampling rate by default#229
jy-tan merged 4 commits intomainfrom
devin/1777429830-adaptive-sampling-default

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 29, 2026

Summary

Update setup agent prompts and onboard wizards to use adaptive sampling mode as the default, while also allowing users to choose fixed mode.

What changed

Agent prompts (phase_create_config.md, phase_cloud_configure_recording.md): Config templates now output recording.sampling.mode: adaptive with base_rate instead of the flat sampling_rate field. The customization flow includes sampling mode selection (adaptive or fixed).

Onboard wizard (onboard/config.go): Recording struct uses nested RecordingSampling with mode: adaptive and base_rate. Generated configs use the new structure.

Cloud wizard (onboard-cloud/):

  • RecordingConfigTable now includes a "Sampling Mode" row that toggles between adaptive/fixed
  • SaveRecordingConfig accepts a samplingMode parameter (defaults to adaptive if empty, validates allowed values)
  • Review step summary shows the selected sampling mode
  • Existing config's sampling mode is loaded from raw YAML to avoid config parser normalization

Agent tool (cloud_save_config): Schema updated with optional sampling_mode enum parameter (adaptive/fixed). SaveCloudConfig passes mode through to SaveRecordingConfig.

Config (config.go): Exported FindConfigFile() for raw YAML inspection by the cloud wizard.

Why

Adaptive sampling automatically reduces recording rate under load, which reduces performance overhead for high-traffic services. Making it the default ensures new setups get this benefit without manual configuration, while still allowing users to opt into fixed mode when they need predictable sampling.

Fixes #223

Review & Testing Checklist for Human

  • Run tusk init and verify generated .tusk/config.yaml contains recording.sampling.mode: adaptive and recording.sampling.base_rate: 1 instead of flat sampling_rate
  • Run cloud onboard wizard and verify the recording config table shows "Sampling Mode" row that toggles between adaptive/fixed
  • Test the cloud wizard with fixed mode selected and verify the saved config reflects mode: fixed
  • Re-run the cloud wizard on a legacy config (without explicit sampling.mode) and verify it defaults to adaptive, not fixed

Notes

  • The cloud wizard preserves the legacy sampling_rate field alongside the new nested fields for backward compatibility with older SDK versions.
  • SaveRecordingConfig defaults to adaptive if an empty mode string is passed and validates that mode is one of adaptive/fixed.
  • loadExistingConfig reads the raw YAML to check if sampling.mode was explicitly set, avoiding the config parser's normalization of absent mode to "fixed".

Link to Devin session: https://app.devin.ai/sessions/82231cf6c58342128ed7bf072ea79f1c
Requested by: @jy-tan

jy-tan added 2 commits April 29, 2026 02:33
Update the setup agent prompts, onboard wizard, and cloud onboard wizard
to use adaptive sampling mode by default instead of fixed mode when
generating new configurations.

Changes:
- Setup agent config templates now use recording.sampling.mode: adaptive
  with recording.sampling.base_rate instead of the deprecated
  recording.sampling_rate
- Onboard wizard (tusk init) generates configs with nested sampling
  config using adaptive mode
- Cloud onboard wizard (tusk init-cloud) saves sampling.mode: adaptive
  and sampling.base_rate alongside the legacy sampling_rate field
- Updated descriptions to mention adaptive sampling behavior
- Updated integration test to verify new fields are saved

Closes #223
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@jy-tan jy-tan marked this pull request as ready for review April 29, 2026 05:19
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/agent/prompts/phase_cloud_configure_recording.md">

<violation number="1" location="internal/agent/prompts/phase_cloud_configure_recording.md:45">
P2: The customization flow documents `fixed` sampling mode but never asks the user to choose a mode, so `fixed` cannot be selected.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread internal/agent/prompts/phase_cloud_configure_recording.md
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ebe039f. Configure here.

Comment thread internal/tui/onboard-cloud/helpers.go
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 10 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/tui/onboard-cloud/save.go">

<violation number="1" location="internal/tui/onboard-cloud/save.go:216">
P2: Validate `samplingMode` before writing it to config; unsupported values can be persisted as-is and create invalid recording settings.</violation>
</file>

<file name="internal/tui/onboard-cloud/helpers.go">

<violation number="1" location="internal/tui/onboard-cloud/helpers.go:199">
P2: The empty-string check here is unreachable: the config parser already normalizes an absent `sampling.mode` to `"fixed"` during validation. For pre-existing configs without an explicit mode, `cfg.Recording.Sampling.Mode` will be `"fixed"` (not `""`), so this fallback to `"adaptive"` never triggers. To honour the PR's intent of defaulting to adaptive, this should check for `"fixed"` when the config file doesn't actually contain the field (e.g., check whether the raw YAML key was present), or default at the point before the config parser normalizes it.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread internal/tui/onboard-cloud/save.go
Comment thread internal/tui/onboard-cloud/helpers.go Outdated
@jy-tan jy-tan merged commit 9d9ff85 into main Apr 29, 2026
14 checks passed
@jy-tan jy-tan deleted the devin/1777429830-adaptive-sampling-default branch April 29, 2026 05:50
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.

Update setup agent and wizard to use adaptive sampling rate by default

2 participants