Skip to content

fix(ton-bridge): clean up plugin and document agent-side duplication bug#30

Merged
xlabtg merged 3 commits intoxlabtg:mainfrom
konard:issue-29-0392afa34f8a
Mar 23, 2026
Merged

fix(ton-bridge): clean up plugin and document agent-side duplication bug#30
xlabtg merged 3 commits intoxlabtg:mainfrom
konard:issue-29-0392afa34f8a

Conversation

@konard
Copy link

@konard konard commented Mar 23, 2026

Summary

Fixes #29

Plugin-side fixes (this PR)

  • Remove unused createRequire import from test file (lint cleanup)
  • Align registry.json description with manifest.json for consistency

Investigation findings

After thorough analysis, the ton-bridge plugin itself is correctly structured and fully compliant with the teleton plugin standard:

  • Exports tools as a function (SDK pattern) ✓
  • All 3 tools (ton_bridge_open, ton_bridge_about, ton_bridge_custom_message) have valid name, description, parameters, and execute
  • manifest.json has all required fields ✓
  • Inline export const manifest has correct sdkVersion and defaultConfig
  • Error handling with PluginSDKError support ✓
  • All 25 unit tests pass ✓
  • No lint errors ✓
  • Plugin validation passes ✓

Root cause of duplication bug (agent-side)

The plugin duplication on restart is a bug in xlabtg/teleton-agent, not in the plugin itself. Specifically:

The fork's startAgent() in src/index.ts is missing the builtinModuleCount property and module array truncation that the original (TONresistor/teleton-agent) has.

What happens on restart:

  1. stopAgent() runs — calls mod.stop() on all modules but does not remove plugin tools from the registry and does not truncate the this.modules array
  2. startAgent() runs again — calls loadEnhancedPlugins() which discovers the same plugins
  3. this.modules.push(mod) appends duplicates to the array
  4. registerPluginTools() silently skips individual tools that already exist (if (this.tools.has(tool.name)) continue), but overwrites pluginToolNames with an empty array (since all tools were skipped)
  5. Result: tools appear duplicated in the UI, and pluginToolNames incorrectly shows 0 tools for the plugin

Fix needed in xlabtg/teleton-agent:

Add module array truncation before re-loading plugins (matching the original repo):

// In constructor, after loadModules():
this.builtinModuleCount = this.modules.length;

// In startAgent(), before loadEnhancedPlugins():
this.modules.length = this.builtinModuleCount;

And in registerPluginTools(), call removePluginTools() before re-registering:

registerPluginTools(pluginName, tools) {
    this.removePluginTools(pluginName); // Clean up before re-registering
    // ... rest of registration
}

This fix should be applied in the xlabtg/teleton-agent repository.

Test plan

  • All 25 existing unit tests pass
  • Plugin validation passes (npm run validate)
  • No lint errors (npm run lint)
  • Plugin loads correctly and exports 3 tools with proper definitions

🤖 Generated with Claude Code

konard and others added 2 commits March 23, 2026 19:21
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: xlabtg#29
- Remove unused createRequire import from test file
- Align registry.json description with manifest.json for consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] Fix ton_bridge fix(ton-bridge): clean up plugin and document agent-side duplication bug Mar 23, 2026
@konard konard marked this pull request as ready for review March 23, 2026 19:34
@konard
Copy link
Author

konard commented Mar 23, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.590899
  • Calculated by Anthropic: $4.590684 USD
  • Difference: $-0.000216 (-0.00%)

🤖 Models used:

  • Tool: Claude
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (2123KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Author

konard commented Mar 23, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@xlabtg xlabtg merged commit 2fca604 into xlabtg:main Mar 23, 2026
6 checks passed
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.

Fix ton_bridge

2 participants