Repository navigation
sleep: match feedback phrases as whole words, so ordinary requests aren't mined as failures - #457
Open
Vidwaan Singhania (Vidwaansinghania) wants to merge 3 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
_detect_feedbackinskillopt_sleep/harvest.pydecides whether a user turn approves or rejects the agent's previous output. Every harvester (Claude Code, Codex, Copilot, Copilot CLI, Cursor, OpenCode, Pi) calls it, andheuristic_minelabels a taskfailwhenever any turn carries a negative signal. It matched phrases with a plain substring test (ph in text.lower()), so phrases fired inside unrelated words.On current
main:Can you play the piano, guitar, and drums in this demo?neg:no,Write a function that undoes the last migrationneg:undoThat's incorrectneg:incorrect,pos:correctneg:incorrectStill not fixedneg:still not,neg:not fixed,pos:fixedneg:still not,neg:not fixedAdd a section on Venice, Italypos:niceRename the prefixed columnspos:fixedIt didn’t work(curly apostrophe)neg:didn'tno thanks, that's not greatpos:thanks,pos:greatThe first row matters most. The opening request isn't feedback at all, but because "piano," contains "no,", the session's task is labelled
failand goes into replay and the held-out gate as a failure.How
functools.lru_cache) as(?<!\w)<phrase>(?!\w). Lookarounds are used instead of\bbecause some phrases end in punctuation (no,). The phrase lists and theSKILLOPT_SLEEP_NEG_FEEDBACK/_POS_FEEDBACKenv-var extensions are unchanged, and user phrases get the same treatment.fixedinsidenot fixedno longer gives a positive signal as well.not,no,never,hardlyor ann'tword, with at most one word in between, is skipped (not great,no thanks,isn't correct,not really perfect). A positive after an unrelated clause still counts (Not what I pictured, but thanks→pos:thanks).’is normalised to'before matching, sodidn’tanddoesn’t workfrom macOS or mobile keyboards are detected.The return type and the
neg:<phrase>/pos:<phrase>format are unchanged, so callers and the LLM miner prompt are unaffected.Tests
tests/test_sleep_feedback_phrases.py(stdlibunittest, no network). It covers substring false positives for both lists,incorrectvscorrect, positives inside negatives, negated positives, curly apostrophes, existing phrases that must still match, and one end-to-end check thatheuristic_minelabels the "piano," requestunknowninstead offail.test_sleep_config_encoding,test_sleep_staging_fanout,test_sleep_engine::test_cycle_stages_only_documents_that_changed,test_harvest_project_scope,test_reproducibility,test_openai_compatible_config,test_benchmark_task_output_paths). They look Windows-specific and are unrelated to this change. All the existing feedback-signal tests (test_sleep_engine,test_sleep_harvest_non_user_records,test_copilot_harvest,test_harvest_copilot_cli,test_harvest_opencode,test_harvest_pi) pass.Not in this PR
Two related things are left for discussion, since they change behaviour more than a matching fix should:
heuristic_mine's docstring says "negative feedback present and no later positive → fail", but the code ignores order: any negative givesfail, even when a later turn says "perfect, thanks". Fixing that needs ordered signals, so it changes howfeedback_signalsis built.Glad to follow up on either if you'd like them.