Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

Randomized trace generation was producing quite long traces with equal probability. This change introduces weighted selection that slightly prefers shorter traces while still allowing longer ones.

Changes

  • New weighted_trace_choice() in spotutils.py: Uses inverse step count weighting (1 / (1 + num_steps)) instead of uniform random.choice()
  • Semantic step counting: Counts trace steps by ; delimiter rather than character length (e.g., 'a; b; cycle{c}' = 3 steps)
  • Updated trace selection in exercisebuilder.py (2 locations) and app.py (1 location)

Example

# For traces with 1, 3, 4, 5... steps:
# step=1:  weight=0.50  → ~27% selection
# step=3:  weight=0.25  → ~10% selection  
# step=11: weight=0.08  → ~5% selection

All traces remain selectable; shorter ones are just more likely.

Original prompt

This section details on the original issue you should resolve

<issue_title>Randomized trace gen leads to quite long traces</issue_title>
<issue_description>New randomized trace gen approach leads to quite long traces. Perhaps we should slightly prefer shorter traces when choosing. That is, still allow longer traces, but weight shorter traces SLIGHTLY higher in the random gen.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Adjust randomized trace generation for shorter traces Weight shorter traces higher in randomized trace selection Nov 29, 2025
Copilot AI requested a review from sidprasad November 29, 2025 18:51
Copilot finished work on behalf of sidprasad November 29, 2025 18:51
@sidprasad
Copy link
Contributor

@copilot instead of counting the LENGTH of a trace for weighting, it should be the number of states in the trace. I think ; count is a good proxy for this

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.

Randomized trace gen leads to quite long traces

2 participants