Repository navigation
[dotnet-port-api] Expose session state count - #1283
Quim Muntal (qmuntal) merged 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| // StateCount returns the number of values stored in the session state. | ||
| func (s *Session) StateCount() int { |
|
Copilot fix review comments. |
Co-authored-by: qmuntal <3747816+qmuntal@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The additive API correctly preserves session locking and zero-value semantics with adequate behavioral coverage.
0 open findings
What changed in this PR
Adds a lock-safe Session.StateCount() API matching the upstream session-state count capability.
Changes:
- Returns stored key count, including zero for nil/uninitialized sessions.
- Tests insertion, replacement, and deletion behavior.
| File | Description |
|---|---|
agent/session.go |
Adds the synchronized state-count accessor. |
agent/session_test.go |
Verifies count behavior across state mutations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Renamed the accessor to |
API consistency review
Changed Go contractAdds Upstream evidence reviewed
AssessmentThe Go Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "github.com"See Network Configuration for more information.
|
Summary
Port the assessed
Microsoft.Agents.AI.AgentSessionStateBag.Countcapability asagent.Session.StateCount(). The method reports the number of stored session-state keys under the session's existing read lock and returns zero for an uninitialized or nil session.Ported .NET PRs
None. The contract was verified directly at pinned .NET revision
0c9944cc9f577d51277ac7c55dbc388b60a577afindotnet/src/Microsoft.Agents.AI.Abstractions/AgentSessionStateBag.cs. The inventoried .NET assemblies are catalog-pinned at version1.22.0.0.Breaking Changes
None intended. This is an additive public API; existing session state behavior is unchanged.
Tests and Examples
TestSessionState_StateCount_TracksValues, covering empty, insertion, replacement, and deletion behavior.go test ./agentgofmt -w agent/session.go agent/session_test.gogit diff --checkNotes
Microsoft.Agents.AI.AgentSessionStateBag.Count(unmapped). Expected catalog maintenance after merge: reassess it as covered, retaining the existing declaring-type mapping toagent.Session.Countreturns the concurrent state dictionary's key/value count. Go maps the session-owned state bag toSession.StateCount()while preserving lock-safe access and nil/zero-value behavior.repo:microsoft/agent-framework-go AgentSessionStateBag Count session state countand PR query with the same syntax, both atperPage: 10and fieldsnumber,title,state,html_url; the final issue query returned no hits, and the only PR hit was broad merged PR Port Abstractions behaviors and structured output #1273, whose direct diff/catalog assessment did not add a count API. Earlier screened groups were excluded because workflow edge metadata is already claimed by closed PR [dotnet-port-api] Expose workflow edge kind metadata #1265, while skills caching options are already present in the current Go implementation.Warning
Firewall blocked 3 domains
The following domains were blocked by the firewall during workflow execution:
proxy.golang.orgstorage.googleapis.comsum.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.