[codex] Improve Slackbot personalization and resilience#1338
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Slackbot’s resilience to GitHub lookup failures, introduces a more structured personalization block derived from TurboPuffer “user facts,” and clarifies model configuration (response vs. memory-synthesis) via Prefect Variables.
Changes:
- Add explicit personalization fields to
UserContextand generate a structured system-prompt personalization section. - Make GitHub issue lookup degrade gracefully on auth / rate-limit / not-found errors.
- Split model configuration into
marvin_ai_model,marvin_bot_model, andmarvin_memory_synthesis_model, and log model settings during runs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/slackbot/src/slackbot/types.py | Expands UserContext to include personalization fields. |
| examples/slackbot/src/slackbot/settings.py | Adds separate settings for response model vs. memory-synthesis model. |
| examples/slackbot/src/slackbot/search.py | Wraps GitHub issue search with targeted error handling. |
| examples/slackbot/src/slackbot/core.py | Loads a personalization snapshot and centralizes system prompt construction. |
| examples/slackbot/src/slackbot/api.py | Logs agent/model configuration and uses the updated agent creation path. |
| examples/slackbot/src/slackbot/_internal/prompting.py | New helper to build structured system prompts with personalization sections. |
| examples/slackbot/src/slackbot/_internal/personalization.py | New personalization snapshot synthesis (fact selection + optional summarization). |
| examples/slackbot/README.md | Documents the new model variables and updated defaults. |
Comments suppressed due to low confidence (1)
examples/slackbot/src/slackbot/core.py:178
create_agent()always wrapssettings.bot_model_nameinAnthropicModel(...). Ifmarvin_ai_model/marvin_bot_modelis set to an OpenAI model name likegpt-5(as the README advertises), this will try to run it through the Anthropic client and fail. Consider either passing the model name directly toAgent(model=...)(letting pydantic-ai select the provider), or branching to construct the correct model/provider based on the selected model name.
ai_model = model or AnthropicModel(
model_name=settings.bot_model_name,
provider=Provider(
api_key=Secret.load(settings.anthropic_key_secret_name, _sync=True).get(), # type: ignore
),
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
145
to
152
| namespace = f"{settings.user_facts_namespace_prefix}{user_id}" | ||
| personalization = load_personalization_snapshot(namespace, user_question) | ||
| try: | ||
| user_notes = query_namespace( | ||
| query_text=user_question, | ||
| namespace=f"{settings.user_facts_namespace_prefix}{user_id}", | ||
| namespace=namespace, | ||
| top_k=5, | ||
| ) |
Comment on lines
+99
to
+105
| "Agent config: response_model=%s memory_synthesis_model=%s temperature=%s max_tool_calls=%s seen_before=%s workspace=%s", | ||
| settings.bot_model_name, | ||
| settings.memory_synthesis_model_name, | ||
| settings.temperature, | ||
| settings.max_tool_calls_per_turn, | ||
| user_context["seen_before"], | ||
| user_context["workspace_name"], |
Comment on lines
+196
to
+197
| except GitHubError as exc: | ||
| return f"GitHub issue search failed: {exc}" |
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 changed
This updates the Slackbot along three related axes:
Why
Marvin had useful personalization data in TurboPuffer, but it was being injected as a thin raw notes blob. That made it harder for the bot to answer like it actually remembers the person, and it also let contradictory stored facts leak into prompt context too easily.
Separately, expired GitHub credentials were causing issue-search failures to bubble up too aggressively. The Slackbot now degrades more safely while still surfacing the outage.
Impact
marvin_bot_modelnow actually works as an override againmarvin_memory_synthesis_modelcan be configured via Prefect Variable, alongside the other model settingsValidation
Ran:
All 13 tests passed.