Skip to content

Pr open harness for OpenHarness.rfm_addon.c#273

Open
guyuming76 wants to merge 4 commits into
HKUDS:mainfrom
guyuming76:PR_OpenHarness
Open

Pr open harness for OpenHarness.rfm_addon.c#273
guyuming76 wants to merge 4 commits into
HKUDS:mainfrom
guyuming76:PR_OpenHarness

Conversation

@guyuming76
Copy link
Copy Markdown
Contributor

I am developing a gtk3+ file manager rfm which can work with terminals https://gitee.com/guyuming76/rfm/tree/openharness/

rfm has an addon mechanism with which i am developing a addon to work with OpenHarness. With the OpenHarness.rfm_addon.c addon, OpenHarness is loaded as an Python module embedded in rfm process. rfm use Rust nushell/reedline library to support multiline input and completions, user inputted prompts are routed to OpenHarness.rfm_addon.c -> rfmOpenHarness.py -> OpenHarness. And i developed some OH tools so that OH can have the currently files in rfm GUI, and for bash file query such as locate and find, OH can show the result list in rfm GUI.

During the development, I made serveral changes to OH (actually AI made them for me). I am creating PR here to find out whether its possible to merge my change or are there better way(I am new to OH and do not really understand it well)

…oh wrappers downstream can call it directly instead of copy existing codes in cli.py:main()

    ┌─────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ 文件                                        │ 改动                                                                                                                                                           │
    ├─────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
    │ src/openharness/services/session_storage.py │ 新增 resolve_session_params() — 封装 --continue / --resume 的全部 session 加载逻辑,返回 {"cwd", "model", "restore_messages", "restore_tool_metadata"} 或 None │
    │ src/openharness/cli.py:main()               │ ~60 行 session 加载逻辑替换为调用 resolve_session_params(),代码量减为 ~25 行                                                                                  │
::: oh*]〉/quit
::: OpenHarness shut down.
::: /usr/lib/python3.13/asyncio/base_events.py:750: RuntimeWarning: coroutine method 'aclose' of 'PoolByteStream.__aiter__' was never awaited
:::   self._ready.clear()
::: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
::: b*]〉

The `PoolByteStream.__aiter__` warning came from `httpcore` (used internally by `httpx`, which powers both `AsyncOpenAI` and `AsyncAnthropic`). When `/quit` was issued, `close_runtime()` cleaned up MCP sessions and hooks but **never closed the API client**. The underlying HTTP connection pool kept `PoolByteStream` async generators alive, and when `shutdown()` called `self._loop.close()`, Python detected those unclosed coroutines.
如果当前还在 OH 某个会话中,运行 /session 命令可以看到 session directory, message count 等,但由于我运行过屏幕清除命令,看不到之前的对话内容,有啥办法可以把当前会话内容重新显示一遍? 或者说哪个命令可以显示出当前会话的session id,以便我退出当前会话后再根据会话 id 检索会话内容
tjb-tech pushed a commit that referenced this pull request May 27, 2026
Close API clients when the runtime shuts down to release HTTP connection pool resources, and surface the active session ID in /session output.

Cherry-picked from PR #273. Excluded the embedded-wrapper session resolver and memory parser API changes because they need a narrower public API design.
@tjb-tech
Copy link
Copy Markdown
Collaborator

已从这个 PR 抽取两个小修到 main:bf5931e。\n\n已合入:\n- runtime shutdown 时关闭 API client,释放 HTTP connection pool;\n- /session 输出当前 Session ID。\n\n没有直接 merge 整个 PR,因为它同时包含 embedded wrapper 用的 session resolver、memory parser public API、API close 和 session UI 等多个不同方向的变更;其中 session resolver/memory parser 还需要更明确的 public API 设计。新提交保留了原作者署名,并补了 close_runtime 和 /session 的回归测试。

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