[PR #4692] feat: add glm specific prompt, leverage its capabilities and use best practices #11069

Closed
opened 2026-02-16 18:15:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4692

State: closed
Merged: No


Summary

  • Add a dedicated system prompt for GLM models (glm.txt).
  • Wire GLM models to use this new prompt instead of the generic Qwen/fallback prompt.
    Background
    Previously, SystemPrompt.provider did not have any GLM-specific handling.
    Any model whose ID did not match the GPT, Gemini, Claude, or Polaris branches fell through to the default:
    return [PROMPT_ANTHROPIC_WITHOUT_TODO] // imported from "./prompt/qwen.txt"
    As a result, GLM sessions were using the qwen.txt system prompt rather than a GLM-optimized one.
    Changes
  1. New GLM prompt
    • Added packages/opencode/src/session/prompt/glm.txt.
    • This prompt:
      • Positions opencode as an interactive CLI assistant.
      • Emphasizes GLM-4.6’s reasoning and analytical strengths.
      • Reinforces security constraints (no malicious code).
      • Encourages structured workflows using TodoWrite, WebFetch, and the existing toolchain.
      • Defines concise communication style and guidance for help/feedback.
  2. System prompt routing for GLM
    • Updated packages/opencode/src/session/system.ts:

      • Imported the new prompt:
        import PROMPT_GLM from "./prompt/glm.txt"

      • Adjusted SystemPrompt.provider to detect GLM models and return the GLM prompt

    • Matching is done on "glm" (case-insensitive) rather than a specific version, so all GLM variants benefit from the new prompt.
      Behavior / Impact

  • GLM-based sessions now receive GLM-specific system instructions tailored to:
    • Software engineering workflows in the opencode environment.
    • Stronger task planning, research, and tool usage guidance.
  • Other providers and models retain their existing prompts:
    • GPT-* and o1/o3 → beast.txt / codex.txt as before.
    • Gemini → gemini.txt
    • Claude → anthropic.txt
    • Polaris → polaris.txt
    • All other non-GLM, non-GPT/Gemini/Claude/Polaris models → qwen.txt (unchanged).

Testing

  • bun turbo typecheck (runs typecheck across all packages) – pass.
  • Manual verification recommended:
    • Start a session with a GLM model (model ID contains "glm").
      • Confirm that behavior aligns with the new GLM system prompt (e.g., references to TodoWrite, WebFetch, and GLM’s reasoning capabilities).
    • Start a session with non-GLM models and confirm their prompts are unchanged.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4692 **State:** closed **Merged:** No --- Summary - Add a dedicated system prompt for GLM models (glm.txt). - Wire GLM models to use this new prompt instead of the generic Qwen/fallback prompt. Background Previously, SystemPrompt.provider did not have any GLM-specific handling. Any model whose ID did not match the GPT, Gemini, Claude, or Polaris branches fell through to the default: return [PROMPT_ANTHROPIC_WITHOUT_TODO] // imported from "./prompt/qwen.txt" As a result, GLM sessions were using the qwen.txt system prompt rather than a GLM-optimized one. Changes 1. New GLM prompt - Added packages/opencode/src/session/prompt/glm.txt. - This prompt: - Positions opencode as an interactive CLI assistant. - Emphasizes GLM-4.6’s reasoning and analytical strengths. - Reinforces security constraints (no malicious code). - Encourages structured workflows using TodoWrite, WebFetch, and the existing toolchain. - Defines concise communication style and guidance for help/feedback. 2. System prompt routing for GLM - Updated packages/opencode/src/session/system.ts: - Imported the new prompt: import PROMPT_GLM from "./prompt/glm.txt" - Adjusted SystemPrompt.provider to detect GLM models and return the GLM prompt - Matching is done on "glm" (case-insensitive) rather than a specific version, so all GLM variants benefit from the new prompt. Behavior / Impact - GLM-based sessions now receive GLM-specific system instructions tailored to: - Software engineering workflows in the opencode environment. - Stronger task planning, research, and tool usage guidance. - Other providers and models retain their existing prompts: - GPT-* and o1/o3 → beast.txt / codex.txt as before. - Gemini → gemini.txt - Claude → anthropic.txt - Polaris → polaris.txt - All other non-GLM, non-GPT/Gemini/Claude/Polaris models → qwen.txt (unchanged). - Testing - bun turbo typecheck (runs typecheck across all packages) – pass. - Manual verification recommended: - Start a session with a GLM model (model ID contains "glm"). - Confirm that behavior aligns with the new GLM system prompt (e.g., references to TodoWrite, WebFetch, and GLM’s reasoning capabilities). - Start a session with non-GLM models and confirm their prompts are unchanged.
yindo added the pull-request label 2026-02-16 18:15:51 -05:00
yindo closed this issue 2026-02-16 18:15:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11069