Skip to content

fix(ai): truthful agent-selection errors + model-path factory resolution - #167

Merged
rbuergi merged 2 commits into
mainfrom
fix/agent-factory-resolution
Jul 2, 2026
Merged

rbuergi merged 2 commits into
mainfrom
fix/agent-factory-resolution

Conversation

@rbuergi

@rbuergi rbuergi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Root-causes the e2e 'agent not found among [the very list containing it]' failure: error clobbering in SelectAgent, path-form model ids missing Id-only factory matching, and the OpenAICompatible config seed never reaching the factory (cold-catalog window failed every agent build). Truthful, actionable errors per failure mode; canonical path→id resolution; config-section fallback in Supports/CreateChatClient. 22 tests green across the selection/resolver/factory surfaces.

🤖 Generated with Claude Code

…resolution

The 'Selected agent X was not found among [X, ...]' lie was a two-layer mask:
(1) SelectAgent clobbered the truthful matched-but-unbuildable error with 'not found';
(2) beneath it, path-form model ids (Provider/OpenAICompatible/qwen-small) missed the
factory's Id-only matching, and AddOpenAICompatible's config seed never reached the
factory's Supports/credentials — any cold catalog window failed EVERY agent build.
Resolver canonicalizes node-path→wire id; the OpenAI factory reads its own config
sections as a snapshot-independent source of truth; resume-recovery normalizes like
the entry boundary. 15+5+2 tests green; solution Release -warnaserror clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses several AI agent selection and model/factory resolution failure modes that produced misleading “agent not found” errors and prevented OpenAICompatible config-seeded models from resolving reliably during cold-start windows. It improves error truthfulness/actionability, normalizes model identifiers across path/id forms, and adds regression tests to pin the observed e2e portal failure.

Changes:

  • Prevents “agent not found” error clobbering when the selected agent is actually matched but cannot be built (missing factory / factory throws), surfacing the real failure instead.
  • Extends credential/model resolution to accept full LanguageModel node paths, adding resolver-backed path→id normalization.
  • Adds OpenAICompatible config-section fallback in Supports()/CreateChatClient() plus tests covering cold-catalog scenarios and path-form selections.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/MeshWeaver.AI.Test/OpenAIFactoryConfigSeededModelTest.cs New regression coverage for OpenAICompatible config-seeded models resolving even with a cold catalog snapshot.
test/MeshWeaver.AI.Test/ChatClientCredentialResolverTest.cs Adds coverage ensuring resolver handles full node-path model selections (provider stamp, credentials, wire id).
test/MeshWeaver.AI.Test/AgentSelectionPathResolutionTest.cs Adds coverage for “matched-but-unbuildable” vs “unmatched” selection error messaging behavior.
src/MeshWeaver.AI/ThreadExecution.cs Normalizes persisted model selection when recovering from the response cell.
src/MeshWeaver.AI/ChatClientCredentialResolver.cs Adds resolver-backed canonicalization for full model node paths and applies it to provider/credential resolution.
src/MeshWeaver.AI/AgentChatClient.cs Avoids overwriting truthful build failures with “agent not found”; adds actionable “no factory resolves model” messaging.
src/MeshWeaver.AI.OpenAI/OpenAIChatClientAgentFactory.cs Adds config-section lookup fallback for config-seeded OpenAICompatible models (Supports/CreateChatClient).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1096 to 1101
// The persisted cell carries the COMPOSER form of the model — the full
// node path ("Provider/OpenAICompatible/qwen-small"). Normalize exactly
// like the entry boundary above (and like Harness on the next line):
// factories/credential resolution key on the bare model id.
ModelName = SelectionId.IdOf(request.ModelName ?? cell!.ModelName),
Harness = SelectionId.IdOf(request.Harness ?? cell!.Harness)
@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   53 files  ± 0     53 suites  ±0   18m 58s ⏱️ - 1m 13s
4 741 tests  - 53  4 630 ✅  - 53  111 💤 ±0  0 ❌ ±0 
4 770 runs   - 24  4 659 ✅  - 24  111 💤 ±0  0 ❌ ±0 

Results for commit 7205c3e. ± Comparison against base commit e770d68.

This pull request removes 182 and adds 129 tests. Note that renamed tests count towards both.
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveAgents_FromHostedSubHub_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveAgents_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveModels_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentSyncedQueryFromHostedHubTest ‑ HostedSubHub_GetQuery_AgentDropdownNamesAreNonEmpty
MeshWeaver.Hosting.Monolith.Test.AgentSyncedQueryFromHostedHubTest ‑ HostedSubHub_GetQuery_ReturnsAgentsAndModels
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ BusinessRulesDoc_RelativeReference_ResolvesToMotorXL
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ Cession_Trace_HubConfiguration
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_LayoutArea_ReturnsContent
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_Overview_ShouldRender
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_PathResolves
…
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.AgenticAI.md")
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.ChatCommands.md")
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.ExecuteScript.md")
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.ExecutiveAssistan"···)
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.McpAuthentication"···)
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.ModelProviderSetu"···)
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.PlatformProviderS"···)
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.ProviderConfigura"···)
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.TeamsBot.md")
MeshWeaver.Persistence.Test.DocumentationCodeBlockCompilationTest ‑ ExecutedCsharpBlocks_MustCompile(embeddedResourceName: "MeshWeaver.Documentation.Data.AI.Tools.MeshPlugin."···)
…

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 3)

781 tests  ±0   674 ✅ ±0   2m 35s ⏱️ +7s
 12 suites ±0   107 💤 ±0 
 12 files   ±0     0 ❌ ±0 

Results for commit 7205c3e. ± Comparison against base commit e770d68.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 1)

1 078 tests   - 182   1 077 ✅  - 182   3m 35s ⏱️ - 1m 34s
   14 suites ±  0       1 💤 ±  0 
   14 files   ±  0       0 ❌ ±  0 

Results for commit 7205c3e. ± Comparison against base commit e770d68.

This pull request removes 182 tests.
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveAgents_FromHostedSubHub_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveAgents_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentPickerProjectionPartitionedTest ‑ PartitionedPath_ObserveModels_PopulatesCombobox
MeshWeaver.Hosting.Monolith.Test.AgentSyncedQueryFromHostedHubTest ‑ HostedSubHub_GetQuery_AgentDropdownNamesAreNonEmpty
MeshWeaver.Hosting.Monolith.Test.AgentSyncedQueryFromHostedHubTest ‑ HostedSubHub_GetQuery_ReturnsAgentsAndModels
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ BusinessRulesDoc_RelativeReference_ResolvesToMotorXL
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ Cession_Trace_HubConfiguration
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_LayoutArea_ReturnsContent
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_Overview_ShouldRender
MeshWeaver.Hosting.Monolith.Test.CessionLayoutAreaTest ‑ MotorXL_PathResolves
…

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 2)

   14 files  ±  0     14 suites  ±0   7m 25s ⏱️ +23s
1 301 tests +129  1 298 ✅ +129  3 💤 ±0  0 ❌ ±0 
1 330 runs  +158  1 327 ✅ +158  3 💤 ±0  0 ❌ ±0 

Results for commit 7205c3e. ± Comparison against base commit e770d68.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 0)

1 581 tests  ±0   1 581 ✅ ±0   5m 21s ⏱️ -10s
   13 suites ±0       0 💤 ±0 
   13 files   ±0       0 ❌ ±0 

Results for commit 7205c3e. ± Comparison against base commit e770d68.

@rbuergi
rbuergi merged commit 577da09 into main Jul 2, 2026
11 checks passed
@rbuergi
rbuergi deleted the fix/agent-factory-resolution branch August 5, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants