token cache improvements#9652
Conversation
|
@codex: review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3be0511c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Insert the context prompt just before the trailing user prompt. It is regenerated on every | ||
| // call and not stored in the session, so keeping it at the end preserves the cached prefix of | ||
| // the earlier messages. | ||
| messages = slices.Insert(messages, len(messages)-1, NewTextCompletionMessage(RoleUser, contextPrompt)) |
There was a problem hiding this comment.
Keep admin AI instructions in a system message
When a project defines ai_instructions, this inserts the new contextPrompt as a user message immediately before the actual user prompt, and that prompt now contains the administrator project-wide instructions. That downgrades those instructions from the previous system prompt to user-level content that the following user message can contradict or override, so configured analyst behavior/guardrails can be ignored. Keep admin instructions in the system prompt or another higher-priority message while moving only truly dynamic dashboard context here.
Useful? React with 👍 / 👎.
|
@codex: review again |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfad59c65f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Insert the context prompt just before the trailing user prompt. It is regenerated on every | ||
| // call and not stored in the session, so keeping it at the end preserves the cached prefix of | ||
| // the earlier messages. | ||
| messages = slices.Insert(messages, len(messages)-1, NewTextCompletionMessage(RoleUser, contextPrompt)) |
There was a problem hiding this comment.
Preserve per-turn context during truncation
When an analyst completion runs long enough for token truncation after tool calls have been appended, this inserted context message is no longer near the tail; maybeTruncateMessages only preserves the first four messages and a suffix, so it can drop the current dashboard filters/time range/date while keeping later tool-call history. In large dashboard sessions, later iterations can therefore query or answer without the per-turn context that previously lived in the always-kept system prompt.
Useful? React with 👍 / 👎.
max_input_tokensconfigurable per connector.prompt_cache_keyfor per session cache for openai connector.Checklist: