CORE-410: cherry-pick auth + repetition fixes from Zambia fork#691
Merged
Conversation
…ndle clock skew (cherry picked from commit 01b41a6)
…rk errors API gateway STANDARD rate kept at 1200 req/min (upstream raised it to 3600) to match core's traffic profile. (cherry picked from commit 30f3685)
…REGION` and `VERTEX_API_GEN_AI_REGION` - Update environment variable names for better specificity. - Refactor related configurations, initialization code, and documentation to align with changes. Upstream career-explorer / jobs MongoDB env-var additions and the non_priority_sector_explorer.py / ingest_sector_document.py scripts dropped — those features do not exist in core compass. (cherry picked from commit 6c00932)
…n sentence corrections [pulumi up] (cherry picked from commit 15b0b77)
…verage
- Update `_detect_stickiness` to handle both consecutive and non-consecutive duplicate questions.
- Introduce new test to validate forced finish behavior upon non-consecutive duplicate questions.
- Refine `_conversation_llm` templates to strictly forbid re-asking or repeating questions.
TURN FLOW + Transition adapted to reference core's existing (a)/(b)/(c) question categories; achievement-question gating and {turn_target} placeholder dropped (not present in core).
(cherry picked from commit 3679765)
…on for EXPLORE_SKILLS_AGENT questions (cherry picked from commit a486465)
…g phase transition [pulumi up] Upstream's counseling sub-phase / sticky-routing / skip-phase / observability ctx-var infrastructure trimmed — those features don't exist in core compass. Core retains the essential transition-aware history-save gate. (cherry picked from commit 2334114)
…rAgent loop detection (cherry picked from commit daf7409)
Country.ZAMBIA is fork-only and not in core's Country enum; the reference broke pytest collection (AttributeError: ZAMBIA) and failed backend CI even though these are deselected evaluation_tests.
nraffa
marked this pull request as ready for review
May 21, 2026 02:04
Comment on lines
+474
to
+479
| # Deduplicate: keep one copy of the repeated question so the NEVER re-ask rule still fires | ||
| state.question_asked_until_now = questions[:-consecutive] + [last] | ||
| # Trim answers_provided to stay in sync with the new question list length | ||
| new_len = len(state.question_asked_until_now) | ||
| if len(state.answers_provided) > new_len: | ||
| state.answers_provided = state.answers_provided[:new_len] |
There was a problem hiding this comment.
Bug: In _flush_if_repeating, trimming answers_provided to [:new_len] creates an off-by-one error, breaking the invariant that len(answers) should be len(questions) - 1.
Severity: MEDIUM
Suggested Fix
In _flush_if_repeating, when trimming the answers_provided list, adjust the slice to [:new_len - 1]. This will correctly maintain the invariant where the number of answers is one less than the number of questions.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: backend/app/agent/explore_experiences_agent_director.py#L474-L479
Potential issue: The `_flush_if_repeating` method incorrectly trims the
`answers_provided` list, causing an off-by-one error. The code is intended to maintain
an invariant where `len(answers) == len(questions) - 1`. However, when the `questions`
list is deduplicated to a `new_len`, the `answers_provided` list is also trimmed to
`new_len`. This makes both lists the same length, breaking the invariant. Consequently,
when the final user answer is appended later, it is dropped by `zip(questions,
answers)`, leading to data loss for downstream tasks.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Summary
Brings the authentication and skills-explorer repetition fixes developed on the Zambia fork over the past months into core Compass. Each change is an atomic
cherry-pick -x(provenance trailer preserved); fork-only features were deliberately excluded.Resolves CORE-410.
Changes
Authentication
01b41a60)30f36852)Skills-explorer repetition / disengagement (the core of the ticket)
_flush_if_repeating,REPETITION_SHORT_CIRCUIT_THRESHOLD) (a486465b)NEVER re-ask+DISENGAGEMENT SIGNALSrules, wrapped around core's existing (a)/(b)/(c) question structure (3679765d)23341141)15b0b771)daf74094)Config
VERTEX_API_REGION→VERTEX_API_EMBEDDINGS_REGION+VERTEX_API_GEN_AI_REGION(embeddings models need their own regional endpoint) (6c00932a)VERTEX_API_*migrationembeddings_model.pyhard-raises ifVERTEX_API_EMBEDDINGS_REGIONis unset (gen-AI only warns + defaults tous-central1). In-repo templates are updated, but before deploying to any environment both new vars must be added to: GitHub Actions secrets, Pulumi config/ESC, and each Cloud Run env (plus every dev's localbackend/.env). Backend will not boot otherwise. Do not merge with[pulumi up]until external envs are updated.Adaptations from upstream (intentional divergences, noted in commit bodies)
3fb9fb60skipped for that reason)Follow-ups (non-blocking)
expect_errors_in_logs=Trueto assert on the specific expected errorxtestFirebase retry tests (parked upstream due to fake-timer issue)_flush_if_repeatingboundary cases