Skip to content

Fix heartbeat tool access via callback pattern#39

Merged
yiwang merged 4 commits into
mainfrom
copilot/fix-heartbeat-issue
Feb 19, 2026
Merged

Fix heartbeat tool access via callback pattern#39
yiwang merged 4 commits into
mainfrom
copilot/fix-heartbeat-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

Heartbeat couldn't execute file operations or bash commands because these tools are defined in localgpt-cli but heartbeat runs in localgpt-core. Core cannot import CLI (circular dependency).

Solution

Added optional ToolFactory callback to inject CLI tools without reversing dependency graph:

// Core defines interface
pub type ToolFactory = Box<dyn Fn(&Config) -> Result<Vec<Box<dyn Tool>>> + Send + Sync>;

// CLI provides implementation
let tool_factory = Box::new(|config| create_cli_tools(config));
HeartbeatRunner::new_with_gate_and_tools(&config, agent_id, gate, Some(tool_factory))?;

Changes

Core crate (localgpt-core/src/heartbeat/)

  • Added ToolFactory type alias and optional field to HeartbeatRunner
  • Added new_with_gate_and_tools() constructor accepting tool factory
  • Extended agent tools from factory in run_once() before execution

CLI crate (localgpt-cli/src/cli/daemon.rs)

  • Daemon wraps create_cli_tools() as factory when spawning heartbeat
  • Updated both background daemon and heartbeat test command

Architecture preserved

  • CLI → Core dependency unchanged
  • Mobile/server builds unaffected (no factory = safe tools only)
  • Backward compatible: existing new_with_gate() calls unchanged

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.pyke.io
    • Triggering command: /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-4fb9e0debc451c7c/build-script-main /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-4fb9e0debc451c7c/build-script-main /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libobject-49a13cd1c17ee472.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libmemchr-80c0d200aa1c5414.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libaddr2line-ed0d1665fe189213.rlib /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libgimli-82f3ba019c4b6344.rlib 89/out/libaws_lc_0_37_1_crypto.a 89/out/8f1694c3e3041570-bignum_montinv_p256.o 89/out/8f1694c3e3041570-p256_montjscalarmul.o 89/out/8f1694c3e3041570-p256_montjscalarmul_alt.o 89/out/4433246e317b5e42-bignum_add_p384.o 89/out/4433246e317b5e42-bignum_deamont_p384.o 89/out/4433246e317b5e42-bignum_deamont_p384_alt.o 89/out/4433246e317b5e42-bignum_littleendian_6.o 89/out/4433246e317b5e42-bignum_montinv_p384.o 89/out/4433246e317b5e42-bignum_montmul_p384.o 89/out/4433246e317b5e42-bignum_montmul_p384_alt.o 89/out/4433246e317b5e42-bignum_montsqr_p384.o 89/out/4433246e317b5e42-bignum_montsqr_p384_alt.o 89/out/4433246e317b5e42-bignum_neg_p384.o 89/out/4433246e317b5e42-bignum_nonzero_6.o (dns block)
    • Triggering command: /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-4fb9e0debc451c7c/build-script-main /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-4fb9e0debc451c7c/build-script-main /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02--check-cfg /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02cfg(docsrs,test) /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02--check-cfg /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02cfg(feature, values()) /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02-C /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02metadata=5a6abc964901ce63 /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e02-C 4390.darling_macro.a7bbcfd54d42fa82-cgu.0.rcgu.o /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e0289/o�� 4390.dgvm9xnnq9ds8yk0ditabp8m1.rcgu.o /home/REDACTED/work/localgpt/localgpt/target/debug/build/aws-lc-sys-e0caf0de8a4e0289/out/ebcd52e9457b6221-x509rset.o 89/o�� 75a994.rlib .rlib ib a42b.rlib ib rlib 35072.rlib (dns block)
    • Triggering command: /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-64084d033ce2d210/build-script-main /home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-64084d033ce2d210/build-script-main -Wl,-Bstatic /home/REDACTED/work/localgpt/localgpt/target/debug/deps/liblzma_rust2-3b5a6f8c5e7b/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libstrsim-8da5906b5f32b006.rlib /home/REDACTED/work/localgpt/localgpt/target/debug/deps/libhmac_sha256-3c934aca59d/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libfnv-1215859a684cad45.rlib /home/REDACTED/work/localgpt/localgpt/target/debug/deps/libureq-56fca58f43c2d6a0.r/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libident_case-0f6ad5d47d62a42b.rlib /home/REDACTED/work/localgpt/localgpt/target/debug/deps/libwebpki_root_certs-88cb8/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libsyn-5a31f41abc6c2f2a.rlib 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.00/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libquote-819bddae12a512e2.rlib 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.01/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libproc_macro2-7e8392b0e59a7afb.rlib 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.02/home/REDACTED/work/localgpt/localgpt/target/debug/deps/libunicode_ident-6c344b3cd407a301.rlib 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.03.rcg�� 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.04.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.05.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.06.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.07.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.08.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.09.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.10.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.build_script_build.31ee2bb2b9f3792a-cgu.11.rcgu.o 2/build_script_build-6aa26c3c24d36ad2.8rpuk2rak7x34azvbpj96633z.rcgu.o rgo/registry/src/home/REDACTED/work/localgpt/localgpt/target/debug/build/ort-sys-64084d033ce2d210//tmp/rustcea7Bnz/rmeta.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Heartbeat still not working</issue_title>
<issue_description>Because it no longer has access to tools like read / write / edit_file, and bash ... do we even have tests for "does heartbeat work" lol? ;-)

I'm still too new to rust to know quite how to get the core crate to import the cli crate, nor has my lesser intelligence ( local glm model ) sorted it out... maybe you'll beat me to it? </issue_description>

<agent_instructions>analyze the code to find out why the heart beat might not working</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 19, 2026 03:20
Co-authored-by: yiwang <142937+yiwang@users.noreply.github.com>
Co-authored-by: yiwang <142937+yiwang@users.noreply.github.com>
Co-authored-by: yiwang <142937+yiwang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix heartbeat functionality not working Fix heartbeat tool access via callback pattern Feb 19, 2026
Copilot AI requested a review from yiwang February 19, 2026 03:31
@yiwang yiwang marked this pull request as ready for review February 19, 2026 03:33
@yiwang yiwang merged commit 2b28f6d into main Feb 19, 2026
5 checks passed
@yiwang yiwang deleted the copilot/fix-heartbeat-issue branch February 19, 2026 03:35
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.

Heartbeat still not working

2 participants