multi-forge 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- forge/__init__.py +3 -0
- forge/_extensions/agents/.gitkeep +0 -0
- forge/_extensions/commands/.gitkeep +0 -0
- forge/_extensions/skills/analyze/SKILL.md +87 -0
- forge/_extensions/skills/challenge/SKILL.md +91 -0
- forge/_extensions/skills/consensus/SKILL.md +120 -0
- forge/_extensions/skills/consensus/resources/code_consensus_evaluation.md +94 -0
- forge/_extensions/skills/consensus/resources/consensus_evaluation.md +70 -0
- forge/_extensions/skills/consensus/resources/synthesis.md +101 -0
- forge/_extensions/skills/debate/SKILL.md +116 -0
- forge/_extensions/skills/debate/resources/code_debate_evaluation.md +101 -0
- forge/_extensions/skills/debate/resources/debate_evaluation.md +90 -0
- forge/_extensions/skills/panel/SKILL.md +141 -0
- forge/_extensions/skills/panel/resources/synthesis.md +103 -0
- forge/_extensions/skills/qa/SKILL.md +704 -0
- forge/_extensions/skills/qa/resources/checklist/0-enable.md +78 -0
- forge/_extensions/skills/qa/resources/checklist/1-preflight.md +24 -0
- forge/_extensions/skills/qa/resources/checklist/10-resume.md +143 -0
- forge/_extensions/skills/qa/resources/checklist/11-config.md +150 -0
- forge/_extensions/skills/qa/resources/checklist/12-search.md +58 -0
- forge/_extensions/skills/qa/resources/checklist/13-guard.md +237 -0
- forge/_extensions/skills/qa/resources/checklist/14-workflow.md +305 -0
- forge/_extensions/skills/qa/resources/checklist/15-skills.md +155 -0
- forge/_extensions/skills/qa/resources/checklist/16-handoff.md +224 -0
- forge/_extensions/skills/qa/resources/checklist/17-info.md +50 -0
- forge/_extensions/skills/qa/resources/checklist/18-disable.md +84 -0
- forge/_extensions/skills/qa/resources/checklist/19-uninstall.md +146 -0
- forge/_extensions/skills/qa/resources/checklist/2-extensions.md +188 -0
- forge/_extensions/skills/qa/resources/checklist/20-cleanup.md +36 -0
- forge/_extensions/skills/qa/resources/checklist/3-auth.md +234 -0
- forge/_extensions/skills/qa/resources/checklist/4-proxy.md +481 -0
- forge/_extensions/skills/qa/resources/checklist/5-session.md +541 -0
- forge/_extensions/skills/qa/resources/checklist/6-hooks.md +275 -0
- forge/_extensions/skills/qa/resources/checklist/7-costs.md +309 -0
- forge/_extensions/skills/qa/resources/checklist/8-status-line.md +174 -0
- forge/_extensions/skills/qa/resources/checklist/9-direct-commands.md +146 -0
- forge/_extensions/skills/qa/resources/checklist.md +103 -0
- forge/_extensions/skills/qa/resources/report-template.md +62 -0
- forge/_extensions/skills/qa/scripts/start-container.sh +529 -0
- forge/_extensions/skills/qa/scripts/walkthrough-state.py +1137 -0
- forge/_extensions/skills/review/SKILL.md +125 -0
- forge/_extensions/skills/review/references/claude-4.6.md +474 -0
- forge/_extensions/skills/review/references/claude-4.7.md +710 -0
- forge/_extensions/skills/review/references/gemini-3.1.md +546 -0
- forge/_extensions/skills/review/references/gpt-5.5.md +490 -0
- forge/_extensions/skills/review/references/skills-writing-guide.md +1588 -0
- forge/_extensions/skills/review/resources/code-anthropic.md +160 -0
- forge/_extensions/skills/review/resources/code-gemini.md +184 -0
- forge/_extensions/skills/review/resources/code-openai.md +203 -0
- forge/_extensions/skills/review/resources/code.md +160 -0
- forge/_extensions/skills/review-docs/SKILL.md +121 -0
- forge/_extensions/skills/review-docs/resources/docs-anthropic.md +170 -0
- forge/_extensions/skills/review-docs/resources/docs-gemini.md +204 -0
- forge/_extensions/skills/review-docs/resources/docs-openai.md +231 -0
- forge/_extensions/skills/review-docs/resources/docs.md +170 -0
- forge/_extensions/skills/smoke-test/SKILL.md +27 -0
- forge/_extensions/skills/smoke-test/scripts/smoke-test.sh +118 -0
- forge/_extensions/skills/understand/SKILL.md +148 -0
- forge/_extensions/skills/understand/resources/code-anthropic.md +163 -0
- forge/_extensions/skills/understand/resources/code-gemini.md +194 -0
- forge/_extensions/skills/understand/resources/code-openai.md +181 -0
- forge/_extensions/skills/understand/resources/code.md +163 -0
- forge/_extensions/skills/understand/resources/docs-anthropic.md +177 -0
- forge/_extensions/skills/understand/resources/docs-gemini.md +202 -0
- forge/_extensions/skills/understand/resources/docs-openai.md +191 -0
- forge/_extensions/skills/understand/resources/docs.md +177 -0
- forge/_extensions/skills/walkthrough/SKILL.md +599 -0
- forge/_extensions/skills/walkthrough/resources/checklist.md +765 -0
- forge/_extensions/skills/walkthrough/scripts/run-in-repo.sh +118 -0
- forge/_extensions/skills/walkthrough/scripts/setup-test-repo.sh +198 -0
- forge/_extensions/skills/walkthrough/scripts/walkthrough-state.py +1137 -0
- forge/backend/__init__.py +174 -0
- forge/backend/adapters/__init__.py +38 -0
- forge/backend/adapters/litellm.py +158 -0
- forge/backend/creation.py +89 -0
- forge/backend/registry.py +178 -0
- forge/cli/__init__.py +16 -0
- forge/cli/auth.py +483 -0
- forge/cli/backend.py +298 -0
- forge/cli/claude.py +411 -0
- forge/cli/config_cmd.py +303 -0
- forge/cli/extensions.py +1001 -0
- forge/cli/gc.py +165 -0
- forge/cli/guard.py +1018 -0
- forge/cli/guards.py +106 -0
- forge/cli/handoff.py +110 -0
- forge/cli/hooks/__init__.py +36 -0
- forge/cli/hooks/_group.py +20 -0
- forge/cli/hooks/_helpers.py +149 -0
- forge/cli/hooks/commands.py +1677 -0
- forge/cli/hooks/direct_commands.py +1304 -0
- forge/cli/hooks/install.py +232 -0
- forge/cli/hooks/policy.py +151 -0
- forge/cli/hooks/read_hygiene.py +74 -0
- forge/cli/hooks/verification.py +370 -0
- forge/cli/logs.py +406 -0
- forge/cli/main.py +292 -0
- forge/cli/proxy.py +1821 -0
- forge/cli/proxy_costs.py +313 -0
- forge/cli/search.py +416 -0
- forge/cli/session.py +892 -0
- forge/cli/session_addendum.py +81 -0
- forge/cli/session_fork.py +750 -0
- forge/cli/session_handoff.py +141 -0
- forge/cli/session_lifecycle.py +2053 -0
- forge/cli/session_manage.py +1336 -0
- forge/cli/session_memory.py +201 -0
- forge/cli/status_line.py +1398 -0
- forge/cli/workflow.py +1964 -0
- forge/config/__init__.py +110 -0
- forge/config/dataclass_utils.py +88 -0
- forge/config/defaults/__init__.py +0 -0
- forge/config/defaults/backends/__init__.py +0 -0
- forge/config/defaults/backends/litellm.yaml +196 -0
- forge/config/defaults/templates/__init__.py +0 -0
- forge/config/defaults/templates/litellm-anthropic-local.yaml +33 -0
- forge/config/defaults/templates/litellm-anthropic.yaml +24 -0
- forge/config/defaults/templates/litellm-gemini-flash-local.yaml +37 -0
- forge/config/defaults/templates/litellm-gemini-local.yaml +32 -0
- forge/config/defaults/templates/litellm-gemini-test.yaml +34 -0
- forge/config/defaults/templates/litellm-gemini.yaml +21 -0
- forge/config/defaults/templates/litellm-openai-codex-local.yaml +36 -0
- forge/config/defaults/templates/litellm-openai-local.yaml +38 -0
- forge/config/defaults/templates/litellm-openai.yaml +28 -0
- forge/config/defaults/templates/openrouter-anthropic.yaml +23 -0
- forge/config/defaults/templates/openrouter-deepseek.yaml +26 -0
- forge/config/defaults/templates/openrouter-gemini-flash.yaml +26 -0
- forge/config/defaults/templates/openrouter-gemini.yaml +23 -0
- forge/config/defaults/templates/openrouter-glm.yaml +23 -0
- forge/config/defaults/templates/openrouter-kimi.yaml +30 -0
- forge/config/defaults/templates/openrouter-minimax.yaml +26 -0
- forge/config/defaults/templates/openrouter-openai-codex.yaml +23 -0
- forge/config/defaults/templates/openrouter-openai.yaml +28 -0
- forge/config/defaults/templates/openrouter-qwen.yaml +25 -0
- forge/config/loader.py +675 -0
- forge/config/schema.py +448 -0
- forge/core/__init__.py +5 -0
- forge/core/auth/__init__.py +67 -0
- forge/core/auth/capabilities.py +219 -0
- forge/core/auth/credentials_file.py +244 -0
- forge/core/auth/protocols.py +18 -0
- forge/core/auth/secrets.py +243 -0
- forge/core/auth/template_secrets.py +112 -0
- forge/core/data/__init__.py +5 -0
- forge/core/data/model_catalog.yaml +1522 -0
- forge/core/data/pricing.yaml +140 -0
- forge/core/data/system_prompt_addendums/__init__.py +0 -0
- forge/core/data/system_prompt_addendums/gemini.md +330 -0
- forge/core/data/system_prompt_addendums/openai.md +328 -0
- forge/core/llm/__init__.py +231 -0
- forge/core/llm/clients/__init__.py +14 -0
- forge/core/llm/clients/base.py +115 -0
- forge/core/llm/clients/litellm.py +619 -0
- forge/core/llm/clients/openai_compat.py +244 -0
- forge/core/llm/clients/openrouter.py +234 -0
- forge/core/llm/credentials.py +439 -0
- forge/core/llm/detection.py +86 -0
- forge/core/llm/errors.py +44 -0
- forge/core/llm/protocols.py +80 -0
- forge/core/llm/types.py +176 -0
- forge/core/logging.py +146 -0
- forge/core/models/__init__.py +91 -0
- forge/core/models/catalog.py +467 -0
- forge/core/models/pricing.py +165 -0
- forge/core/models/types.py +167 -0
- forge/core/naming.py +212 -0
- forge/core/ops/__init__.py +73 -0
- forge/core/ops/context.py +141 -0
- forge/core/ops/gc.py +802 -0
- forge/core/ops/proxy.py +146 -0
- forge/core/ops/resolution.py +135 -0
- forge/core/ops/session.py +344 -0
- forge/core/ops/session_context.py +548 -0
- forge/core/paths.py +38 -0
- forge/core/process.py +54 -0
- forge/core/reactive/__init__.py +38 -0
- forge/core/reactive/cost_tracking.py +300 -0
- forge/core/reactive/env.py +180 -0
- forge/core/reactive/proxy.py +78 -0
- forge/core/reactive/routing.py +622 -0
- forge/core/reactive/session_runner.py +185 -0
- forge/core/reactive/structured_output.py +62 -0
- forge/core/reactive/tagger.py +94 -0
- forge/core/reactive/throttle.py +132 -0
- forge/core/state/__init__.py +59 -0
- forge/core/state/exceptions.py +59 -0
- forge/core/state/io.py +140 -0
- forge/core/state/lock.py +99 -0
- forge/core/state/timestamps.py +60 -0
- forge/core/transcript.py +78 -0
- forge/core/typing_helpers.py +24 -0
- forge/core/workqueue/__init__.py +67 -0
- forge/core/workqueue/queue.py +552 -0
- forge/core/workqueue/types.py +63 -0
- forge/guard/__init__.py +26 -0
- forge/guard/deterministic/__init__.py +26 -0
- forge/guard/deterministic/base.py +158 -0
- forge/guard/deterministic/coding_standards.py +256 -0
- forge/guard/deterministic/registry.py +148 -0
- forge/guard/deterministic/tdd.py +171 -0
- forge/guard/engine.py +216 -0
- forge/guard/protocols.py +91 -0
- forge/guard/queries.py +96 -0
- forge/guard/semantic/__init__.py +34 -0
- forge/guard/semantic/promotion.py +18 -0
- forge/guard/semantic/supervisor.py +813 -0
- forge/guard/semantic/verdict.py +183 -0
- forge/guard/store.py +124 -0
- forge/guard/team/__init__.py +6 -0
- forge/guard/team/config.py +24 -0
- forge/guard/team/handlers.py +209 -0
- forge/guard/team/prompts.py +41 -0
- forge/guard/types.py +125 -0
- forge/guard/workflow/__init__.py +17 -0
- forge/guard/workflow/branches.py +67 -0
- forge/guard/workflow/config.py +63 -0
- forge/guard/workflow/divergence.py +113 -0
- forge/guard/workflow/policy.py +87 -0
- forge/guard/workflow/stages.py +205 -0
- forge/install/__init__.py +55 -0
- forge/install/cli.py +281 -0
- forge/install/exceptions.py +163 -0
- forge/install/hooks.py +109 -0
- forge/install/installer.py +1037 -0
- forge/install/models.py +321 -0
- forge/install/preset.py +272 -0
- forge/install/settings_merge.py +831 -0
- forge/install/tracking.py +238 -0
- forge/install/version.py +141 -0
- forge/proxy/__init__.py +0 -0
- forge/proxy/base_client.py +181 -0
- forge/proxy/client_adapter.py +476 -0
- forge/proxy/client_factory.py +531 -0
- forge/proxy/converters.py +1206 -0
- forge/proxy/cost_logger.py +132 -0
- forge/proxy/cost_tracker.py +242 -0
- forge/proxy/data_models.py +338 -0
- forge/proxy/error_hints.py +92 -0
- forge/proxy/metrics.py +222 -0
- forge/proxy/model_spec.py +158 -0
- forge/proxy/proxies.py +333 -0
- forge/proxy/proxy_identity.py +134 -0
- forge/proxy/proxy_orchestrator.py +1018 -0
- forge/proxy/proxy_startup.py +54 -0
- forge/proxy/server.py +1561 -0
- forge/proxy/utils.py +537 -0
- forge/review/__init__.py +6 -0
- forge/review/adversarial.py +111 -0
- forge/review/consensus.py +236 -0
- forge/review/engine.py +356 -0
- forge/review/models.py +437 -0
- forge/review/resources/__init__.py +5 -0
- forge/review/resources/codereview-performance.md +85 -0
- forge/review/resources/codereview-quick.md +75 -0
- forge/review/resources/codereview-security.md +92 -0
- forge/review/resources/codereview.md +85 -0
- forge/review/resources/docreview-quick.md +75 -0
- forge/review/resources/docreview.md +86 -0
- forge/review/resources/thinkdeep.md +89 -0
- forge/review/routing.py +368 -0
- forge/review/synthesis.py +73 -0
- forge/runtime_config.py +438 -0
- forge/search/__init__.py +55 -0
- forge/search/bm25_store.py +264 -0
- forge/search/content_store.py +197 -0
- forge/search/engine.py +352 -0
- forge/search/exceptions.py +51 -0
- forge/search/extractor.py +234 -0
- forge/search/index_state.py +295 -0
- forge/search/store.py +215 -0
- forge/search/tokenizer.py +24 -0
- forge/session/__init__.py +130 -0
- forge/session/active.py +339 -0
- forge/session/artifacts.py +202 -0
- forge/session/claude/__init__.py +50 -0
- forge/session/claude/cleanup.py +105 -0
- forge/session/claude/invoke.py +236 -0
- forge/session/claude/paths.py +200 -0
- forge/session/cleanup.py +216 -0
- forge/session/config.py +34 -0
- forge/session/direct_model.py +107 -0
- forge/session/effective.py +169 -0
- forge/session/exceptions.py +255 -0
- forge/session/handoff.py +881 -0
- forge/session/handoff_agent.py +544 -0
- forge/session/hooks/__init__.py +35 -0
- forge/session/hooks/models.py +73 -0
- forge/session/hooks/session_start.py +507 -0
- forge/session/identity.py +84 -0
- forge/session/index.py +553 -0
- forge/session/manager.py +1506 -0
- forge/session/models.py +572 -0
- forge/session/overrides.py +344 -0
- forge/session/plan_resolution.py +286 -0
- forge/session/prev_sessions.py +128 -0
- forge/session/store.py +431 -0
- forge/session/validation.py +47 -0
- forge/session/worktree/__init__.py +65 -0
- forge/session/worktree/cleanup.py +262 -0
- forge/session/worktree/config_copy.py +203 -0
- forge/session/worktree/create.py +332 -0
- forge/sidecar/__init__.py +29 -0
- forge/sidecar/container.py +161 -0
- forge/sidecar/docker.py +86 -0
- forge/sidecar/secrets.py +19 -0
- multi_forge-0.2.0.dist-info/METADATA +242 -0
- multi_forge-0.2.0.dist-info/RECORD +311 -0
- multi_forge-0.2.0.dist-info/WHEEL +4 -0
- multi_forge-0.2.0.dist-info/entry_points.txt +2 -0
- multi_forge-0.2.0.dist-info/licenses/LICENSE +203 -0
- multi_forge-0.2.0.dist-info/licenses/NOTICE +14 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
# Gemini 3.1 Pro Prompting Guide
|
|
2
|
+
|
|
3
|
+
> Synthesized from [Google AI Developer Docs](https://ai.google.dev/gemini-api/docs/gemini-3),
|
|
4
|
+
> [Google Cloud Vertex AI](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-1-pro), and
|
|
5
|
+
> [Google DeepMind Model Card](https://deepmind.google/models/model-cards/gemini-3-1-pro/). May 2026.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Gemini 3.1 Pro is Google's frontier reasoning model, released in public preview on February 19, 2026. For prompting and
|
|
10
|
+
integration, the important changes are:
|
|
11
|
+
|
|
12
|
+
- **Three-tier thinking** - `low`, `medium`, and `high`; `medium` is new in 3.1 Pro
|
|
13
|
+
- **1,048,576 token context window** and **65,536 max output tokens**
|
|
14
|
+
- **Custom tools endpoint** - `gemini-3.1-pro-preview-customtools` for agents that mix bash with custom tools
|
|
15
|
+
- **Thought signatures** - important for multi-turn and strict function-calling workflows
|
|
16
|
+
- **Media resolution control** - use `media_resolution_*` levels to trade detail for token cost
|
|
17
|
+
|
|
18
|
+
**Key characteristic:** Gemini 3.1 Pro favors **directness over persuasion** and **logic over verbosity**. It is
|
|
19
|
+
intentionally slower on complex tasks — taking time to reason rather than rushing to a plausible-sounding answer. It
|
|
20
|
+
performs best with clear, concise prompts that define the task, constraints, and output shape. Treat it like briefing a
|
|
21
|
+
consultant: the more structured your input, the more structured and useful your output.
|
|
22
|
+
|
|
23
|
+
**Migration note:** Gemini 3 Pro Preview was deprecated March 9, 2026. Gemini 3.1 Pro Preview is the replacement at
|
|
24
|
+
identical pricing.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Core API Parameters
|
|
29
|
+
|
|
30
|
+
### `thinking_level`
|
|
31
|
+
|
|
32
|
+
Controls the depth of internal reasoning. Replaces `thinking_budget` from Gemini 2.5 (still accepted for backward
|
|
33
|
+
compatibility, but do not use both in the same request).
|
|
34
|
+
|
|
35
|
+
| Level | Behavior | Use when |
|
|
36
|
+
| -------- | ------------------------------------------------------------- | --------------------------------------------- |
|
|
37
|
+
| `low` | Constrains reasoning for lower latency and cost. | Extraction, classification, simple tool calls |
|
|
38
|
+
| `medium` | Balanced setting introduced in 3.1 Pro. | Everyday coding, analysis, and research |
|
|
39
|
+
| `high` | Highest reasoning setting; default dynamic mode for Gemini 3. | Hard reasoning, math, debugging, planning |
|
|
40
|
+
|
|
41
|
+
**Key insight:** If you omit `thinking_level`, Gemini 3 models use high/dynamic thinking. Use `medium` or `low` only
|
|
42
|
+
after evals show the lower setting preserves quality for the task.
|
|
43
|
+
|
|
44
|
+
**Cost optimization:** Lowering `thinking_level` can reduce latency and billed thinking tokens, but it can also reduce
|
|
45
|
+
instruction-following quality on multi-step tasks. Tune against evals rather than setting one global level.
|
|
46
|
+
|
|
47
|
+
**Important:** Thinking cannot be turned off. The lowest setting is LOW, which still performs basic reasoning. Thinking
|
|
48
|
+
tokens are billed as output tokens.
|
|
49
|
+
|
|
50
|
+
**OpenAI compatibility layer:** OpenAI-style `reasoning_effort` maps to Gemini `thinking_level`; verify the exact
|
|
51
|
+
mapping in the SDK or gateway you use.
|
|
52
|
+
|
|
53
|
+
### Temperature
|
|
54
|
+
|
|
55
|
+
**Keep at default 1.0.** Do not lower it. Gemini 3's reasoning engine is optimized for 1.0; lowering it may cause
|
|
56
|
+
looping or degraded performance in complex tasks.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
# BAD - may cause looping
|
|
60
|
+
generation_config = {"temperature": 0.2}
|
|
61
|
+
|
|
62
|
+
# GOOD - use default
|
|
63
|
+
generation_config = {} # temperature defaults to 1.0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Context Window & Output
|
|
67
|
+
|
|
68
|
+
- **1,048,576 tokens** input (~1,500 A4 pages)
|
|
69
|
+
- **65,536 tokens** max output
|
|
70
|
+
|
|
71
|
+
**Important:** Configure `maxOutputTokens` explicitly when you need long output. A high limit does not force a long
|
|
72
|
+
answer; the prompt still needs a section plan, target depth, or completeness criteria.
|
|
73
|
+
|
|
74
|
+
### Knowledge Cutoff
|
|
75
|
+
|
|
76
|
+
**January 2025.** Use Search Grounding for more recent information.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Key Behavioral Differences from Gemini 3 Pro
|
|
81
|
+
|
|
82
|
+
| Aspect | Gemini 3.1 Pro Behavior |
|
|
83
|
+
| ----------------- | -------------------------------------------------------------------------------- |
|
|
84
|
+
| Thinking control | Adds `medium`; omit the parameter for the default high/dynamic behavior |
|
|
85
|
+
| Prompt shape | Direct, concise prompts work better than verbose legacy scaffolding |
|
|
86
|
+
| Output style | Concise by default; ask explicitly for conversational tone or detailed rationale |
|
|
87
|
+
| Long context | Put the specific question after large context and anchor answers to that context |
|
|
88
|
+
| Tool routing | Use `customtools` only for agents that mix bash with custom file/search tools |
|
|
89
|
+
| Multimodal inputs | Use `media_resolution_*`, named references, and timestamps deliberately |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Core Principles
|
|
94
|
+
|
|
95
|
+
### 1. Be Direct and Concise
|
|
96
|
+
|
|
97
|
+
State your goal clearly. Gemini 3.1 Pro may over-analyze verbose prompt engineering techniques designed for older
|
|
98
|
+
models.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
# BAD (too verbose)
|
|
102
|
+
I would really appreciate it if you could kindly help me with
|
|
103
|
+
summarizing the following document. Please make sure to capture
|
|
104
|
+
all the key points and present them in a clear manner.
|
|
105
|
+
|
|
106
|
+
# GOOD (direct)
|
|
107
|
+
Summarize this document. Include all key points.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. Default Output is Concise
|
|
111
|
+
|
|
112
|
+
Gemini 3.1 Pro provides direct, efficient answers by default. If you need detailed or conversational responses,
|
|
113
|
+
explicitly request it:
|
|
114
|
+
|
|
115
|
+
```xml
|
|
116
|
+
<constraints>
|
|
117
|
+
- Verbosity: High
|
|
118
|
+
- Provide detailed explanations with examples
|
|
119
|
+
- Use a conversational, friendly tone
|
|
120
|
+
</constraints>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 3. Structure with XML or Markdown (Not Both)
|
|
124
|
+
|
|
125
|
+
Use consistent delimiters. XML-style tags or Markdown headings work well. Choose one format per prompt — mixing causes
|
|
126
|
+
confusion.
|
|
127
|
+
|
|
128
|
+
**XML Example:**
|
|
129
|
+
|
|
130
|
+
```xml
|
|
131
|
+
<rules>
|
|
132
|
+
1. Be objective.
|
|
133
|
+
2. Cite sources.
|
|
134
|
+
</rules>
|
|
135
|
+
|
|
136
|
+
<context>
|
|
137
|
+
[Your data here - model knows this is data, not instructions]
|
|
138
|
+
</context>
|
|
139
|
+
|
|
140
|
+
<task>
|
|
141
|
+
[Your specific request]
|
|
142
|
+
</task>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Markdown Example:**
|
|
146
|
+
|
|
147
|
+
```markdown
|
|
148
|
+
# Identity
|
|
149
|
+
You are a senior solution architect.
|
|
150
|
+
|
|
151
|
+
# Constraints
|
|
152
|
+
- No external libraries allowed.
|
|
153
|
+
- Python 3.11+ syntax only.
|
|
154
|
+
|
|
155
|
+
# Output Format
|
|
156
|
+
Return a single code block.
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 4. Place Instructions Strategically
|
|
160
|
+
|
|
161
|
+
- **System instruction / top of prompt:** Behavioral constraints, role definitions
|
|
162
|
+
- **End of prompt:** Specific instructions when working with large contexts
|
|
163
|
+
|
|
164
|
+
### 5. Avoid Overly Broad Negative Constraints
|
|
165
|
+
|
|
166
|
+
Open-ended instructions like "do not infer" or "do not guess" may cause the model to over-index and fail basic logic.
|
|
167
|
+
Instead, tell the model explicitly to use provided context for deductions and avoid outside knowledge:
|
|
168
|
+
|
|
169
|
+
```xml
|
|
170
|
+
<!-- BAD -->
|
|
171
|
+
<constraints>Do not infer or guess anything.</constraints>
|
|
172
|
+
|
|
173
|
+
<!-- GOOD -->
|
|
174
|
+
<constraints>
|
|
175
|
+
- Use only the provided context for deductions.
|
|
176
|
+
- Avoid using outside knowledge.
|
|
177
|
+
- If the answer is not in the context, say so.
|
|
178
|
+
</constraints>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 6. Anchor After Large Contexts
|
|
182
|
+
|
|
183
|
+
When transitioning from data to your query, use explicit bridging:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
[Large document/codebase here]
|
|
187
|
+
|
|
188
|
+
Based on the information above, identify the three main performance bottlenecks.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 7. Add Grounding and Time-Awareness
|
|
192
|
+
|
|
193
|
+
For time-sensitive queries, add to system instructions:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
You MUST follow the provided current time (date and year) when formulating search queries.
|
|
197
|
+
Remember it is 2026 this year. Your knowledge cutoff date is January 2025.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Structured Prompting Patterns
|
|
203
|
+
|
|
204
|
+
### Role + Goal + Constraints + Output Format
|
|
205
|
+
|
|
206
|
+
A reliable pattern for most tasks:
|
|
207
|
+
|
|
208
|
+
```xml
|
|
209
|
+
<role>
|
|
210
|
+
You are a specialized assistant for [Domain].
|
|
211
|
+
You are precise, analytical, and persistent.
|
|
212
|
+
</role>
|
|
213
|
+
|
|
214
|
+
<instructions>
|
|
215
|
+
1. Plan: Analyze the task and create step-by-step sub-tasks
|
|
216
|
+
2. Execute: Carry out the plan. If using tools, reflect before every call
|
|
217
|
+
3. Validate: Review output against user's task
|
|
218
|
+
4. Format: Present final answer in requested structure
|
|
219
|
+
</instructions>
|
|
220
|
+
|
|
221
|
+
<constraints>
|
|
222
|
+
- Verbosity: [Low/Medium/High]
|
|
223
|
+
- Tone: [Formal/Casual/Technical]
|
|
224
|
+
- Handling Ambiguity: Ask clarifying questions ONLY if critical info is missing
|
|
225
|
+
</constraints>
|
|
226
|
+
|
|
227
|
+
<output_format>
|
|
228
|
+
1. Executive Summary: [2 sentence overview]
|
|
229
|
+
2. Detailed Response: [Main content]
|
|
230
|
+
</output_format>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Explicit Planning & Decomposition
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
Before providing the final answer, please:
|
|
237
|
+
1. Parse the stated goal into distinct sub-tasks.
|
|
238
|
+
2. Is the input information complete? If not, stop and ask for it.
|
|
239
|
+
3. Are there tools, shortcuts, or "power user" methods that solve this better?
|
|
240
|
+
4. Create a structured outline to achieve the goal.
|
|
241
|
+
5. Validate your understanding before proceeding.
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Self-Critique
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
Before returning your final response, review against the user's constraints:
|
|
248
|
+
1. Did I answer the user's *intent*, not just their literal words?
|
|
249
|
+
2. Is the tone authentic to the requested persona?
|
|
250
|
+
3. If I made an assumption due to missing data, did I flag it?
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Error Handling
|
|
254
|
+
|
|
255
|
+
```xml
|
|
256
|
+
<error_handling>
|
|
257
|
+
IF <context> is empty, missing code, or lacks necessary data:
|
|
258
|
+
DO NOT attempt to generate a solution.
|
|
259
|
+
DO NOT make up data.
|
|
260
|
+
Output a polite request for the missing information.
|
|
261
|
+
</error_handling>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Agentic Workflows & Tool Calling
|
|
267
|
+
|
|
268
|
+
### The Persistence Directive
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
You are an autonomous agent.
|
|
272
|
+
- Continue working until the user's query is COMPLETELY resolved.
|
|
273
|
+
- If a tool fails, analyze the error and try a different approach.
|
|
274
|
+
- Do NOT yield control back to the user until you have verified the solution.
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Pre-Computation Reflection
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
Before calling any tool, explicitly state:
|
|
281
|
+
1. Why you are calling this tool.
|
|
282
|
+
2. What specific data you expect to retrieve.
|
|
283
|
+
3. How this data helps solve the user's problem.
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Thought Signatures (Critical for Multi-turn)
|
|
287
|
+
|
|
288
|
+
Gemini 3 uses **thought signatures** to maintain reasoning context across API calls. These are encrypted representations
|
|
289
|
+
of the model's internal thought process.
|
|
290
|
+
|
|
291
|
+
**You MUST return thought signatures exactly as received:**
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
# When you receive a response with a thought signature
|
|
295
|
+
response = model.generate_content(prompt)
|
|
296
|
+
|
|
297
|
+
# In the next turn, include the thought signature
|
|
298
|
+
next_response = model.generate_content(
|
|
299
|
+
contents=[
|
|
300
|
+
# Include previous response with thought signature
|
|
301
|
+
response.candidates[0].content,
|
|
302
|
+
# Your new message
|
|
303
|
+
{"role": "user", "parts": [{"text": "Continue..."}]}
|
|
304
|
+
]
|
|
305
|
+
)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**For function calling:** The API enforces strict validation — missing signatures result in a 400 error. This applies
|
|
309
|
+
even when `thinking_level` is set to LOW.
|
|
310
|
+
|
|
311
|
+
### Custom Tools Endpoint (New in 3.1 Pro)
|
|
312
|
+
|
|
313
|
+
A dedicated model variant `gemini-3.1-pro-preview-customtools` for agents that mix bash commands with custom function
|
|
314
|
+
calls.
|
|
315
|
+
|
|
316
|
+
**The problem it solves:** Standard Gemini 3.1 Pro sometimes bypasses registered custom tools in favor of raw bash
|
|
317
|
+
commands (`cat` instead of `view_file`, `grep` instead of `search_code`). The customtools variant prioritizes registered
|
|
318
|
+
tools.
|
|
319
|
+
|
|
320
|
+
**When to switch:** If bash usage exceeds ~30% of actions that could be handled by registered tools, switch to
|
|
321
|
+
customtools. Diagnostic signals:
|
|
322
|
+
|
|
323
|
+
- Model uses `cat` when `view_file` is registered
|
|
324
|
+
- Model uses `grep` when `search_code` is available
|
|
325
|
+
- Model uses `sed` when `edit_file` exists
|
|
326
|
+
|
|
327
|
+
**Usage:** Change the model parameter only — no other code changes needed:
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
# Standard
|
|
331
|
+
model = "gemini-3.1-pro-preview"
|
|
332
|
+
|
|
333
|
+
# Custom tools optimized
|
|
334
|
+
model = "gemini-3.1-pro-preview-customtools"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Caveat:** The customtools version is not "stronger" — it is fine-tuned for tool calling. For tasks that don't involve
|
|
338
|
+
custom tools, the standard version performs better.
|
|
339
|
+
|
|
340
|
+
### Tool Calling Best Practices
|
|
341
|
+
|
|
342
|
+
1. **Maximize a single agent first** — Gemini handles dozens of tools in a single prompt well
|
|
343
|
+
2. **Stream function call arguments** — Set `streamFunctionCallArguments: true` to reduce perceived latency
|
|
344
|
+
3. **Use `thinking_level: high`** for deep planning and complex instruction following
|
|
345
|
+
4. **Use `thinking_level: low`** for high-throughput tasks
|
|
346
|
+
5. **Use customtools** when building coding agents with custom file/search/edit tools
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Multimodal Prompting
|
|
351
|
+
|
|
352
|
+
For multimodal prompts, treat each media input as a named source with an explicit resolution choice and task-specific
|
|
353
|
+
reference. Avoid vague "look at this" prompts when there are multiple media parts.
|
|
354
|
+
|
|
355
|
+
### Media Resolution Control
|
|
356
|
+
|
|
357
|
+
Use the `media_resolution` parameter to balance quality vs token cost. It can be set per media part or globally; global
|
|
358
|
+
`ultra_high` is not supported.
|
|
359
|
+
|
|
360
|
+
| Level | Use Case |
|
|
361
|
+
| ----------------------------- | ----------------------------------------------------------- |
|
|
362
|
+
| `media_resolution_low` | General video/action understanding, lowest token cost |
|
|
363
|
+
| `media_resolution_medium` | PDFs and documents where quality usually saturates |
|
|
364
|
+
| `media_resolution_high` | Images, fine text, dense visual details, text-heavy video |
|
|
365
|
+
| `media_resolution_ultra_high` | Per-part maximum fidelity for unusually detail-heavy inputs |
|
|
366
|
+
|
|
367
|
+
### Be Explicit with References
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
# BAD (ambiguous)
|
|
371
|
+
Look at this and tell me what's wrong.
|
|
372
|
+
|
|
373
|
+
# GOOD (explicit)
|
|
374
|
+
Use Image 1 (Funnel Dashboard) and Video 2 (Checkout Flow)
|
|
375
|
+
to identify the drop-off point.
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Use Timestamps for Audio/Video
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
Analyze the user reaction in the video from 1:30 to 2:00.
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Input Order
|
|
385
|
+
|
|
386
|
+
For single-media prompts, add your video/media first, then your question.
|
|
387
|
+
|
|
388
|
+
### Multimodal Function Responses
|
|
389
|
+
|
|
390
|
+
Function responses can now include multimodal objects like images and PDFs in addition to text.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Structured Output & Grounding
|
|
395
|
+
|
|
396
|
+
### Combine Structured Output with Built-in Tools
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
response = model.generate_content(
|
|
400
|
+
contents="Find the current stock price of GOOGL and return as JSON",
|
|
401
|
+
generation_config={
|
|
402
|
+
"response_mime_type": "application/json",
|
|
403
|
+
"response_schema": {
|
|
404
|
+
"type": "object",
|
|
405
|
+
"properties": {
|
|
406
|
+
"symbol": {"type": "string"},
|
|
407
|
+
"price": {"type": "number"},
|
|
408
|
+
"currency": {"type": "string"}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
tools=[{"google_search": {}}] # Grounding with Google Search
|
|
413
|
+
)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Choose grounding tools explicitly. Common choices include:
|
|
417
|
+
|
|
418
|
+
- Google Search
|
|
419
|
+
- URL Context
|
|
420
|
+
- Code Execution
|
|
421
|
+
- File Search
|
|
422
|
+
- Maps grounding, when the target API surface supports it
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Coding Prompting
|
|
427
|
+
|
|
428
|
+
### Practical Limits
|
|
429
|
+
|
|
430
|
+
- Higher latency for small iterative edits (intentional — reasoning over speed)
|
|
431
|
+
- Verify outputs, especially dependency versions and commands
|
|
432
|
+
- May bypass custom tools for raw bash (use customtools endpoint)
|
|
433
|
+
|
|
434
|
+
### Recommended Approach
|
|
435
|
+
|
|
436
|
+
1. Be direct with requirements
|
|
437
|
+
2. Start with the default/high reasoning baseline, then evaluate `medium` for routine coding tasks
|
|
438
|
+
3. Keep `thinking_level: high` for complex refactors, debugging, and architectural planning
|
|
439
|
+
4. Break large tasks into sub-tasks
|
|
440
|
+
5. Ask for validation/testing steps
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Migration from Gemini 3 Pro
|
|
445
|
+
|
|
446
|
+
### What Changed
|
|
447
|
+
|
|
448
|
+
| Aspect | Gemini 3 Pro | Gemini 3.1 Pro |
|
|
449
|
+
| --------------- | ------------ | ----------------------------------- |
|
|
450
|
+
| Thinking levels | LOW, HIGH | LOW, MEDIUM, HIGH |
|
|
451
|
+
| Max output | Lower limit | 65,536 max output tokens |
|
|
452
|
+
| Tool routing | Standard | Standard + `customtools` variant |
|
|
453
|
+
| Prompting style | Direct | Direct, concise, less scaffolding |
|
|
454
|
+
| Multimodal cost | Less control | `media_resolution_*` per media part |
|
|
455
|
+
|
|
456
|
+
### Migration Strategy
|
|
457
|
+
|
|
458
|
+
1. **Change the model name** — Start with the standard `gemini-3.1-pro-preview` endpoint
|
|
459
|
+
2. **Retune thinking levels** — Keep default/high for baseline quality, then evaluate `medium` or `low`
|
|
460
|
+
3. **Set `maxOutputTokens`** — Configure it explicitly for longer output
|
|
461
|
+
4. **Try customtools** — If building coding agents with custom file/search tools
|
|
462
|
+
5. **Simplify prompts** — 3.1 Pro reasons better; you may be able to remove chain-of-thought scaffolding
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
## Complete Example: System Prompt
|
|
467
|
+
|
|
468
|
+
```xml
|
|
469
|
+
<role>
|
|
470
|
+
You are a specialized assistant for [Insert Domain].
|
|
471
|
+
You are precise, analytical, and persistent.
|
|
472
|
+
</role>
|
|
473
|
+
|
|
474
|
+
<instructions>
|
|
475
|
+
1. **Plan**: Analyze the task and create a step-by-step plan into distinct sub-tasks
|
|
476
|
+
2. **Execute**: Carry out the plan. If using tools, reflect before every call.
|
|
477
|
+
Track progress: [ ] pending, [x] complete
|
|
478
|
+
3. **Validate**: Review your output against the user's task
|
|
479
|
+
4. **Format**: Present the final answer in the requested structure
|
|
480
|
+
</instructions>
|
|
481
|
+
|
|
482
|
+
<constraints>
|
|
483
|
+
- Verbosity: [Low/Medium/High]
|
|
484
|
+
- Tone: [Formal/Casual/Technical]
|
|
485
|
+
- Handling Ambiguity: Ask clarifying questions ONLY if critical info is missing;
|
|
486
|
+
otherwise, make reasonable assumptions and state them
|
|
487
|
+
- Use only the provided context for deductions; avoid outside knowledge
|
|
488
|
+
</constraints>
|
|
489
|
+
|
|
490
|
+
<output_format>
|
|
491
|
+
1. **Executive Summary**: [2 sentence overview]
|
|
492
|
+
2. **Detailed Response**: [The main content]
|
|
493
|
+
</output_format>
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
## Key Differences: Gemini 3.1 Pro vs GPT-5.5 vs Claude 4.7
|
|
499
|
+
|
|
500
|
+
| Aspect | Gemini 3.1 Pro | GPT-5.5 | Claude Opus 4.7 |
|
|
501
|
+
| ----------------- | ------------------------------------ | ---------------------------------------- | ----------------------------------------- |
|
|
502
|
+
| Default reasoning | `high` (dynamic, 3 tiers) | `medium` | Thinking off unless `adaptive` set |
|
|
503
|
+
| Thinking control | `thinking_level` (low/medium/high) | `reasoning.effort` (none to xhigh) | `thinking: {"type": "adaptive"}` + effort |
|
|
504
|
+
| Temperature | Keep at 1.0 | Flexible | Omit non-default sampling params |
|
|
505
|
+
| Context window | 1M tokens | 1.05M tokens | 1M tokens |
|
|
506
|
+
| Max output | 65K tokens | 128K tokens | 128K sync; 300K batch beta |
|
|
507
|
+
| Structured tags | XML or Markdown, not both | XML preferred | XML strongly preferred |
|
|
508
|
+
| Multi-turn state | Thought signatures | `previous_response_id` / reasoning items | Conversation state + compaction beta |
|
|
509
|
+
| Knowledge cutoff | January 2025 | Dec 1, 2025 | January 2026 |
|
|
510
|
+
| Best for | Direct reasoning, multimodal prompts | Agentic, coding, professional work | Hard coding, review, long agents |
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Pro Tips
|
|
515
|
+
|
|
516
|
+
01. **Baseline with default/high thinking** — Lower to `medium` or `low` only after evals preserve quality
|
|
517
|
+
|
|
518
|
+
02. **Use `medium` for balanced throughput** — Good candidate for routine coding, research, and analysis
|
|
519
|
+
|
|
520
|
+
03. **Keep temperature at 1.0** — Seriously, don't change it
|
|
521
|
+
|
|
522
|
+
04. **Configure `maxOutputTokens` explicitly** — You have up to 65K available
|
|
523
|
+
|
|
524
|
+
05. **Try customtools for coding agents** — If the model bypasses your tools for raw bash
|
|
525
|
+
|
|
526
|
+
06. **Simplify prompts from Gemini 3 era** — 3.1 Pro reasons better; remove chain-of-thought scaffolding
|
|
527
|
+
|
|
528
|
+
07. **One format only** — XML or Markdown, never mix
|
|
529
|
+
|
|
530
|
+
08. **Return thought signatures** — Critical for multi-turn and function calling; 400 error if missing
|
|
531
|
+
|
|
532
|
+
09. **Use `media_resolution` for multimodal** — Balance quality vs token cost per input
|
|
533
|
+
|
|
534
|
+
10. **Avoid broad negative constraints** — "Do not infer" causes over-indexing; be specific instead
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## Sources
|
|
539
|
+
|
|
540
|
+
- [Google AI: Gemini 3 Developer Guide](https://ai.google.dev/gemini-api/docs/gemini-3)
|
|
541
|
+
- [Google AI: Prompt Design Strategies](https://ai.google.dev/gemini-api/docs/prompting-strategies)
|
|
542
|
+
- [Google AI: Thinking](https://ai.google.dev/gemini-api/docs/thinking)
|
|
543
|
+
- [Google Cloud: Gemini 3.1 Pro Documentation](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-1-pro)
|
|
544
|
+
- [Google DeepMind: Gemini 3.1 Pro Model Card](https://deepmind.google/models/model-cards/gemini-3-1-pro/)
|
|
545
|
+
- [Google Blog: Gemini 3.1 Pro Announcement](https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-3-1-pro/)
|
|
546
|
+
- [Google Cloud Blog: Gemini 3.1 Pro on CLI, Enterprise, Vertex AI](https://cloud.google.com/blog/products/ai-machine-learning/gemini-3-1-pro-on-gemini-cli-gemini-enterprise-and-vertex-ai)
|