Skip to content

Add TreeNode validation to prevent detached nodes causing inconsistent tool results#1044

Draft
Copilot wants to merge 61 commits intomasterfrom
copilot/ensure-live-llm-tests
Draft

Add TreeNode validation to prevent detached nodes causing inconsistent tool results#1044
Copilot wants to merge 61 commits intomasterfrom
copilot/ensure-live-llm-tests

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Detached TreeNodes (nodes without parent chain) cause contradictory tool call results: get_topic() returns child count from metadata while list_children() returns empty from missing edgeCollection.

Changes

TreeNode Validation

  • Added isValidTreeNode() to verify node structure before use
  • Validates parent chain exists for non-root nodes (proves tree connectivity)
  • Verifies edgeCollection presence for child enumeration
  • Rejects detached nodes with console warnings

Integration

  • Validates currentNode in sendMessage() before passing to tool execution
  • Falls back to undefined if node is detached or invalid
  • Prevents tools from receiving inconsistent tree state

Implementation

private isValidTreeNode(node?: TopicNode): boolean {
  if (!node || typeof node.path !== 'function') return false
  
  const path = node.path()
  // Non-root nodes must have parent to prove tree connectivity
  if (path && path.length > 0 && !node.parent) {
    console.warn('Detached TreeNode detected:', path)
    return false
  }
  
  if (!node.edgeCollection) {
    console.warn('TreeNode missing edgeCollection:', path)
    return false
  }
  
  return true
}

Detached nodes now rejected early with diagnostic logging, eliminating metadata vs structure inconsistencies.

Original prompt

Ensure the live LLM tests run successfully


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 30, 2026 21:07
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title [WIP] Ensure live LLM tests run successfully Relax LLM test regex to accept descriptive verb forms Jan 30, 2026
Copilot AI requested a review from thomasnordquist January 30, 2026 21:20
Copilot AI and others added 5 commits January 30, 2026 21:35
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Relax LLM test regex to accept descriptive verb forms Add Playwright tests for LLM chat frontend with API key integration Jan 30, 2026
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Add Playwright tests for LLM chat frontend with API key integration Document gpt-4o usage and OpenAI reasoning parameter limitations Jan 30, 2026
Copilot AI and others added 4 commits January 30, 2026 21:59
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Document gpt-4o usage and OpenAI reasoning parameter limitations Standardize LLM configuration on gpt-5-mini with reasoning_effort and eliminate code duplication Jan 30, 2026
Copilot AI and others added 3 commits January 31, 2026 16:20
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Implement LLM tool calling with MCP-style function execution and comprehensive testing Implement MCP-style tool calling for LLM with MQTT topic tree integration Jan 31, 2026
Copilot AI and others added 2 commits January 31, 2026 18:00
… refactor proposals

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
…ersist)

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Implement MCP-style tool calling for LLM with MQTT topic tree integration Implement LLM chat with MCP-style tool calling for MQTT topic exploration Jan 31, 2026
Copilot AI changed the title Implement LLM chat with MCP-style tool calling for MQTT topic exploration Implement MCP-style tool calling with live progress and human-readable UX Jan 31, 2026
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Copilot AI changed the title Implement MCP-style tool calling with live progress and human-readable UX Implement MCP-style tool calling for LLM with human-readable display Jan 31, 2026
Copilot AI and others added 9 commits January 31, 2026 20:20
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
…ugging

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
… Thinking

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
…nfo including results

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
- Add optional chaining to tc.function.name and tc.function.arguments (fixes undefined error)
- Create getReadableName() helper to map tool names to human-readable labels
- Update chip labels to show readable names (e.g., 'List Topics: kitchen')
- Update debug panel headers to show readable names
- Improves user understanding of what tools were executed

Fixes: can't access property 'name', tc.function is undefined

Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
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