You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,7 @@ If no new rule is detected -> do not update the file.
91
91
- Upstream sync automation must track real `google-gemini/gemini-cli` CLI changes (flags/models/features), not TypeScript SDK surface diffs, and open actionable repository issues for required SDK follow-up.
92
92
- Automatically opened upstream sync issues must include change summary/checklist and assign Copilot by default.
93
93
- For `google-gemini/gemini-cli` repo sync/update work, always inspect `submodules/google-gemini-cli/gemini-rs/core/models.json` and reconcile SDK model constants against that bundled catalog because it is the repo-authoritative model source.
94
+
- When adapting the SDK to upstream Gemini CLI changes, prioritize reflecting real CLI-specific behavior while keeping the `GeminiClient` / `GeminiThread` contract coherent with `GeminiSharpSDK.Extensions.AI` and `GeminiSharpSDK.Extensions.AgentFramework`.
94
95
- At the end of implementation/code-change tasks, create a git commit unless the user explicitly says not to, so the workspace ends in a reviewable state.
95
96
- Run verification in this order:
96
97
- focused tests for changed behavior
@@ -132,6 +133,7 @@ If no new rule is detected -> do not update the file.
132
133
- CI/release full-solution runs must exclude auth-required tests using `-- --treenode-filter "/*/*/*/*[RequiresGeminiAuth!=true]"` so pipelines remain non-auth and deterministic.
133
134
- Cross-platform non-auth smoke must run `gemini` from local installation in CI and verify unauthenticated behavior explicitly (for example `gemini login status` in isolated profile returns "Not logged in"), proving binary discovery + process launch on each platform.
134
135
- Real Gemini integration tests must rely on existing local Gemini CLI login/session only; do not read or require `OPENAI_API_KEY` in test setup.
136
+
- Adapter regression coverage is critical: when CLI contract changes affect streaming/events/options, keep the `Extensions.AI` and `Extensions.AgentFramework` tests green in the same pass.
135
137
- Do not use nullable `TryGetSettings()` + early `return` skip patterns in real integration tests; resolve required settings directly and fail fast with actionable errors when missing.
136
138
- Do not bypass integration tests on Windows with unconditional early returns; keep tests cross-platform for supported Gemini CLI environments.
137
139
- Parser changes require tests in `ThreadEventParserTests` for supported and invalid payloads.
Gemini CLI now emits `stream-json`events such as `init`, `message`, `tool_use`, `tool_result`, `result`, and `error`.
9
9
Without strict parsing rules and synchronized turn execution, SDK behavior can diverge under concurrency and protocol evolution.
10
10
User rule in this repository explicitly forbids inline string literals for protocol token matching.
11
11
12
12
## Decision
13
13
14
14
1. Centralize protocol tokens in `GeminiProtocolConstants`.
15
15
2. Parse events/items only through constant-based switches.
16
-
3. Serialize execution per `GeminiThread` instance with `SemaphoreSlim`.
16
+
3. Support the current `stream-json` contract first, while tolerating a limited set of legacy persisted fixtures/events where needed for backward-compatible tests.
17
+
4. Serialize execution per `GeminiThread` instance with `SemaphoreSlim`.
Copy file name to clipboardExpand all lines: docs/ADR/003-microsoft-extensions-ai-integration.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Implement `IChatClient` from `Microsoft.Extensions.AI.Abstractions` in a **separ
17
17
18
18
2.**Custom AIContent types** — Rich Gemini items (command execution, file changes, MCP tool calls, web searches, multi-agent collaboration) are surfaced as typed `AIContent` subclasses rather than being flattened to text. This preserves full fidelity of Gemini output.
19
19
20
-
3.**Gemini-specific options via AdditionalProperties** — Standard `ChatOptions` properties (`ModelId`, `ConversationId`) map directly. Gemini-unique features use `gemini:*` prefixed keys in `ChatOptions.AdditionalProperties` (e.g., `gemini:sandbox_mode`, `gemini:reasoning_effort`).
20
+
3.**Gemini-specific options via AdditionalProperties** — Standard `ChatOptions` properties (`ModelId`, `ConversationId`) map directly. Gemini-unique features use `gemini:*` prefixed keys in `ChatOptions.AdditionalProperties` (for example `gemini:sandbox_mode`). Options not supported by the current headless CLI contract fail fast instead of silently degrading.
21
21
22
22
4.**Thread-per-call with ConversationId resume** — Each `GetResponseAsync` call creates or resumes a `GeminiThread`. Thread ID flows via `ChatResponse.ConversationId` for multi-turn continuity.
- SDK participates in .NET AI ecosystem: DI registration, middleware pipelines, provider swapping.
56
56
- Consumers get logging, caching, and telemetry for free via M.E.AI middleware.
57
57
- Rich Gemini items preserved as typed content, not lost.
58
+
- Adapter behavior stays aligned with the real installed CLI contract instead of a guessed chat abstraction.
58
59
59
60
### Negative
60
61
61
62
- Impedance mismatch: Gemini is an agentic coding tool, not a simple chat API. Multi-turn via message history doesn't map cleanly (uses thread resume instead).
Copy file name to clipboardExpand all lines: docs/Features/agent-framework-integration.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Enable GeminiSharpSDK consumers to use Microsoft Agent Framework (`AIAgent`) on
48
48
49
49
- New custom `AIAgent` runtime implementation parallel to `ChatClientAgent`
50
50
- Microsoft Agent Framework hosting/workflows helpers (`Microsoft.Agents.AI.Hosting`, durable agents, DevUI)
51
-
-Changes to core SDK execution, thread state, parsing, or CLI contracts
51
+
-Redefining core SDK execution, thread state, parsing, or CLI contracts beyond consuming the already-supported `stream-json` runtime
52
52
53
53
---
54
54
@@ -102,6 +102,7 @@ Enable GeminiSharpSDK consumers to use Microsoft Agent Framework (`AIAgent`) on
102
102
- Side effects / emitted events: creates singleton `GeminiChatClient` and singleton/keyed `ChatClientAgent`
103
103
- Idempotency: follows standard DI additive registration semantics; repeated registration adds additional descriptors
104
104
- Error handling: null guard exceptions on registration inputs; runtime agent execution errors are delegated to existing `GeminiChatClient` / MAF behaviour
105
+
- CLI specificity: the agent layer inherits the current Gemini headless contract (`--prompt ... --output-format stream-json`) through `GeminiChatClient`; this package does not introduce a second transport model
105
106
- Security / permissions: no new permissions beyond existing `gemini` CLI prerequisites; MAF function invocation remains opt-in through consumer-supplied tools/options
106
107
- Feature flags / toggles: none
107
108
- Performance / SLAs: registration-time object construction only; no extra background work
| EDGE-001 | MAF decorates `IChatClient` with middleware | Unit | Agent-resolved chat client still exposes `ChatClientMetadata` with provider `GeminiCLI`|`GeminiAgentServiceCollectionExtensionsTests.AddGeminiAIAgent_RegistersAIAgentAndChatClient`, `AddKeyedGeminiAIAgent_RegistersKeyedAgent`|
169
170
| EDGE-002 | Keyed agent configuration preserves instructions and default model | Unit |`ChatClientAgentOptions` and `ChatClientMetadata` reflect configured values |`GeminiAgentServiceCollectionExtensionsTests.AddKeyedGeminiAIAgent_WithConfiguration_AppliesKeyedAgentOptions`|
171
+
| EDGE-003 | Agent execution uses the same CLI-specific chat adapter contract as direct `IChatClient` usage | Unit | No alternate transport or extra provider abstraction is introduced by the agent layer | covered by DI composition tests over `GeminiChatClient`|
-Generic tuning mappings not exposed by the current headless Gemini CLI contract (for example `Temperature`, `TopP`, `TopK`, and unsupported reasoning flags)
34
34
35
35
---
36
36
@@ -41,8 +41,9 @@ Enable GeminiSharpSDK to participate as a first-class provider in the `Microsoft
41
41
- Multiple `ChatMessage` entries are concatenated into a single prompt while preserving original message chronology (Gemini CLI is single-prompt-per-turn).
42
42
-`ChatOptions.Tools` is silently ignored; tool results surface as custom `AIContent` types.
43
43
-`GetService<ChatClientMetadata>()` returns provider name `"GeminiCLI"` with default model from options.
44
-
- Streaming events map item-level, not token-level.
45
-
- Turn failures (`TurnFailedEvent`) propagate as `InvalidOperationException`.
44
+
- Streaming maps the real CLI event sequence (`init`, `message`, `tool_use`, `tool_result`, `result`, `error`), not token-level deltas.
45
+
- Unsupported CLI options fail fast when `GeminiThread` cannot express them through the current headless contract.
46
+
- Turn failures propagate from CLI `error` events or process/runtime failures as `InvalidOperationException`.
0 commit comments