Skip to content

fix: preserve code blocks in PR status summary without treating them as tasks#855

Merged
stranske merged 5 commits intomainfrom
fix/task-decomposer-slash-splitting
Jan 12, 2026
Merged

fix: preserve code blocks in PR status summary without treating them as tasks#855
stranske merged 5 commits intomainfrom
fix/task-decomposer-slash-splitting

Conversation

@stranske
Copy link
Copy Markdown
Owner

@stranske stranske commented Jan 12, 2026

Summary

Fixes the issue where code examples in issue bodies were being incorrectly parsed in the PR Automated Status Summary:

  • Code patterns like tasks: inside YAML examples were detected as section headings
  • List items like - example item inside code blocks were converted to task checkboxes

Changes

  1. Added isCodeFenceLine() helper - Detects ```` and ~~~ code fence boundaries

  2. Updated normaliseChecklist() - Tracks insideCodeBlock state and skips checkbox normalization inside code blocks

  3. Updated extractListBlocks() and extractListBlocksWithOffsets() - Treat code block content as continuation, not block boundaries

  4. Updated collectSections() - Skips heading detection when inside code blocks (prevents tasks: in YAML from being detected as a section header)

Behavior

Code blocks are now:

  • ✅ Preserved in the output (not stripped)
  • ✅ Excluded from heading detection
  • ✅ Excluded from checkbox normalization

Example

Before:

#### Tasks
- [ ] Real task one
- [ ] tasks:           <-- code fence content wrongly converted
- [ ]   - YAML example <-- code fence content wrongly converted
- [ ] Real task two

After:

#### Tasks
- [ ] Real task one

\`\`\`yaml
tasks:
  - YAML example task
\`\`\`

- [ ] Real task two

Tests

  • All 598 tests pass
  • Added 2 new test cases for code block handling

…d slashes

The task decomposer was incorrectly splitting compound words like
'additions/removals' or file paths like 'src/utils' into separate tasks
because it matched any '/' character.

This caused the agents:apply-suggestions workflow to corrupt issue bodies
by creating spurious subtasks like:
- Color-coded additions (verify: confirm completion in repo)
- removals (verify: confirm completion in repo)

Fix:
- task_decomposer._split_task_parts: Only split on spaced slashes ' / '
  (indicating alternatives) not unspaced slashes (compound words/paths)
- issue_optimizer._is_large_task: Only flag tasks with spaced slashes
  as 'large' requiring decomposition

Closes: Issue with corrupted tasks in PRs #4355 and #4353
Copilot AI review requested due to automatic review settings January 12, 2026 16:03
@agents-workflows-bot
Copy link
Copy Markdown
Contributor

⚠️ Action Required: Unable to determine source issue for PR #855. The PR title, branch name, or body must contain the issue number (e.g. #123, branch: issue-123, or the hidden marker ).

@github-actions github-actions bot added the autofix Opt-in automated formatting & lint remediation label Jan 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 12, 2026

Automated Status Summary

Head SHA: 73898aa
Latest Runs: ⏳ pending — Gate
Required contexts: Gate / gate, Health 45 Agents Guard / Enforce agents workflow protections
Required: core tests (3.11): ⏳ pending, core tests (3.12): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 92.21%
Baseline 85.00%
Delta +7.21%
Minimum 70.00%
Status ✅ Pass

Top Coverage Hotspots (lowest coverage)

File Coverage Missing
scripts/workflow_health_check.py 62.6% 28
scripts/classify_test_failures.py 62.9% 37
scripts/ledger_validate.py 65.3% 63
scripts/mypy_return_autofix.py 82.6% 11
scripts/ledger_migrate_base.py 85.5% 13
scripts/fix_cosmetic_aggregate.py 92.3% 1
scripts/coverage_history_append.py 92.8% 2
scripts/workflow_validator.py 93.3% 4
scripts/update_autofix_expectations.py 93.9% 1
scripts/pr_metrics_tracker.py 95.7% 3
scripts/generate_residual_trend.py 96.6% 1
scripts/build_autofix_pr_comment.py 97.0% 2
scripts/aggregate_agent_metrics.py 97.2% 0
scripts/fix_numpy_asserts.py 98.1% 0
scripts/sync_test_dependencies.py 98.3% 1

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

No scope information available

Tasks

  • No tasks defined

Acceptance criteria

  • No acceptance criteria defined

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 12, 2026

🤖 Keepalive Loop Status

PR #855 | Agent: Codex | Iteration 0/5

Current State

Metric Value
Iteration progress [----------] 0/5
Action wait (missing-agent-label)
Disposition skipped (transient)
Gate success
Tasks 0/5 complete
Timeout 45 min (default)
Timeout usage 2m elapsed (5%, 43m remaining)
Keepalive ❌ disabled
Autofix ❌ disabled

🔍 Failure Classification

| Error type | infrastructure |
| Error category | resource |
| Suggested recovery | Confirm the referenced resource exists (repo, PR, branch, workflow, or file). |

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 12, 2026

Status | ✅ no new diagnostics
History points | 1
Timestamp | 2026-01-12 17:53:14 UTC
Report artifact | autofix-report-pr-855
Remaining | 0
New | 0
No additional artifacts

@github-actions
Copy link
Copy Markdown
Contributor

Autofix updated these files:

  • tests/scripts/test_issue_optimizer.py

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a bug where the task decomposer was incorrectly splitting compound words and file paths containing unspaced slashes (like additions/removals or src/utils) into separate tasks. The fix changes the logic to only split on spaced slashes (/), which typically indicate alternatives or multiple options.

Changes:

  • Updated _split_task_parts() in task_decomposer.py to only split on / instead of any /
  • Updated _is_large_task() in issue_optimizer.py to only flag tasks with / as large
  • Added comprehensive tests to verify spaced slashes are still split while compound words are preserved

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
scripts/langchain/task_decomposer.py Changed slash splitting from regex pattern matching any / to simple string split on /
scripts/langchain/issue_optimizer.py Updated large task detection to only flag tasks with / instead of any /
tests/scripts/test_task_decomposer.py Renamed test and added new test cases for compound word preservation
tests/scripts/test_issue_optimizer.py Added comprehensive tests for slash handling in _is_large_task

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Compound words should NOT be flagged as large
assert not issue_optimizer._is_large_task("Color-coded additions/removals")
assert not issue_optimizer._is_large_task("Update src/utils module")

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

This line has trailing whitespace. Consider removing it to maintain consistent code formatting.

Copilot uses AI. Check for mistakes.
if any(sep in lowered for sep in (" and ", " + ", " & ", " then ", "; ")):
return True
return bool(re.search(r"\s\+\s", lowered) or ", " in task or "/" in task)
return bool(re.search(r"\s\+\s", lowered) or ", " in task or " / " in task)
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The capability_check.py module contains a similar function _is_multi_action_task (line 180) that also checks for "/" in task. This will have the same issue as the functions fixed in this PR - it will incorrectly flag compound words like "additions/removals" and paths like "src/utils" as multi-action tasks. Consider updating that function to check for " / " in task instead for consistency with this fix.

Copilot uses AI. Check for mistakes.
The Automated Status Summary in PR bodies was extracting checkbox patterns
(- [ ]) from inside fenced code blocks and treating them as tasks.

For example, code examples like:
```python
tasks = ['- [ ] example task']
```

Were being parsed as actual tasks, corrupting the PR body.

Fix:
- Add stripCodeBlocks() function that removes fenced code blocks
  (both ``` and ~~~ style) before parsing
- Apply code block stripping in collectSections() before extracting tasks
- Add regression tests for code block handling

This is the actual fix for the corrupted tasks issue - the previous commit
(task decomposer slash splitting) addressed a different but related problem.
@stranske stranske changed the title fix: Prevent task decomposer from splitting compound words on unspaced slashes fix: Strip code blocks before parsing tasks + fix slash splitting Jan 12, 2026
- Add isCodeFenceLine() helper to detect ``` and ~~~ fences
- Update normaliseChecklist() to skip checkbox normalization inside code blocks
- Update extractListBlocks() to continue through code blocks
- Update extractListBlocksWithOffsets() similarly for offset tracking
- Update collectSections() to skip heading detection inside code blocks

This fixes the issue where code examples in issue bodies containing
patterns like 'tasks:' or '- example item' were being incorrectly
detected as section headings or converted to task checkboxes.

Code blocks are now:
1. Preserved in the output (not stripped)
2. Excluded from heading detection
3. Excluded from checkbox normalization

Closes #TBD
@stranske stranske changed the title fix: Strip code blocks before parsing tasks + fix slash splitting fix: preserve code blocks in PR status summary without treating them as tasks Jan 12, 2026
…k.py

Per Copilot reviewer feedback: capability_check.py contains a similar
function _is_multi_action_task that also checks for '/' in task. This
had the same issue - incorrectly flagging compound words like
'additions/removals' and paths like 'src/utils' as multi-action tasks.

Changes:
- Updated _is_multi_action_task to check for ' / ' (spaced slash) instead
- Added comprehensive tests for the fix
@stranske stranske merged commit 5cb67bb into main Jan 12, 2026
37 checks passed
@stranske stranske deleted the fix/task-decomposer-slash-splitting branch January 12, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autofix Opt-in automated formatting & lint remediation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants