Skip to content

fix: default Codex approval policy to on-request - #6

Open
artemgetmann wants to merge 15 commits into
linuz90:mainfrom
artemgetmann:fix/codex-approval-on-request-default
Open

fix: default Codex approval policy to on-request#6
artemgetmann wants to merge 15 commits into
linuz90:mainfrom
artemgetmann:fix/codex-approval-on-request-default

Conversation

@artemgetmann

Copy link
Copy Markdown
Contributor

Summary

  • change default CODEX_APPROVAL_POLICY fallback in runtime config from never to on-request
  • update .env.example and README examples to match

Why

Threads were defaulting to approval=never, which blocks escalation flow for privileged commands.

Validation

  • bun run typecheck
  • env -u CODEX_APPROVAL_POLICY bun -e "import { CODEX_APPROVAL_POLICY } from './src/config.ts'; console.log(CODEX_APPROVAL_POLICY);" -> on-request

- what: switched to single-preview message edits, lowered stream throttle defaults, added streaming diagnostics, and added synthetic progressive tail updates for single-block SDK responses.

- why: real Claude runs often return one final text block, which looked like no streaming in Telegram even for long replies.

- files: src/handlers/streaming.ts, src/session.ts, src/config.ts, .env.example, README.md, CLAUDE.md.

- risk: synthetic fallback adds a short post-generation animation delay on long responses and increases edit frequency; tuned via env vars and debug logs for rollback.
- what: integrated Codex SDK session flow, added runtime model switching (/model + /assistant), short Claude model aliases (opus 4.6 / sonnet 4.5), and a new /policy command that reports sandbox/approval/allowed paths.

- why: provide full Telegram-side control over assistant/runtime behavior while keeping safety settings inspectable and reducing model command friction.

- files: updated src/session.ts, src/config.ts, src/security.ts, src/handlers/commands.ts, src/index.ts, src/handlers/index.ts, src/types.ts, package.json, bun.lock, README.md, and .env.example.

- risk: medium; large multi-file behavioral change across routing/safety/runtime config, mitigated with typecheck and targeted runtime probes (model parsing, sandbox behavior, home-dir write checks).
- what: add CLAUDE_REASONING_EFFORT (default high), expose Claude runtime effort in /policy, and implement ALLOWED_PATHS base/extra/remove composition with ~/.codex included in defaults.

- why: align runtime behavior with desired Claude-first reasoning and make path access easy to tighten/expand without rewriting full allowlists.

- files: .env.example, README.md, src/config.ts, src/handlers/commands.ts, src/session.ts.

- risk: higher Claude effort increases latency/token usage by default; ALLOWED_PATHS behavior changed from simple override-only docs to composable controls (ALLOWED_PATHS override remains supported).
- what: add beginner macOS setup, common failure fixes, auth quick choices, and a real assistant workspace example layout.

- why: reduce setup failures and make it explicit that AI_WORKING_DIR must be separate from the bot repository.

- files: README.md

- risk: low; docs-only change with no runtime behavior impact.
- what: add CLAUDE_REASONING_EFFORT (default high), expose Claude runtime effort in /policy, and implement ALLOWED_PATHS base/extra/remove composition with ~/.codex included in defaults.

- why: align runtime behavior with desired Claude-first reasoning and make path access easy to tighten/expand without rewriting full allowlists.

- files: .env.example, README.md, src/config.ts, src/handlers/commands.ts, src/session.ts.

- risk: higher Claude effort increases latency/token usage by default; ALLOWED_PATHS behavior changed from simple override-only docs to composable controls (ALLOWED_PATHS override remains supported).
- what: integrated Codex SDK session flow, added runtime model switching (/model + /assistant), short Claude model aliases (opus 4.6 / sonnet 4.5), and a new /policy command that reports sandbox/approval/allowed paths.

- why: provide full Telegram-side control over assistant/runtime behavior while keeping safety settings inspectable and reducing model command friction.

- files: updated src/session.ts, src/config.ts, src/security.ts, src/handlers/commands.ts, src/index.ts, src/handlers/index.ts, src/types.ts, package.json, bun.lock, README.md, and .env.example.

- risk: medium; large multi-file behavioral change across routing/safety/runtime config, mitigated with typecheck and targeted runtime probes (model parsing, sandbox behavior, home-dir write checks).
- what: default session/restart/temp/audit files to AI_RUNTIME_DIR under AI_WORKING_DIR, create runtime directories at startup, and keep legacy /tmp session-file read fallback.

- why: keep assistant context and bot runtime state in one workspace root for simpler setup, migration, and backup.

- files: src/config.ts, src/session.ts, README.md, CLAUDE.md, .env.example, .gitignore.

- risk: users relying on /tmp file locations may need env overrides; mitigated by backwards-compatible aliases and legacy session loading.
…fety prompt

- what: switch default AI_RUNTIME_DIR to <AI_WORKING_DIR>/sessions, include resolved session/runtime/temp paths in SAFETY_PROMPT, and load legacy session history from both .runtime and /tmp.

- why: make session state easier to find/manage, ensure the agent knows exact session location, and preserve resume continuity during runtime-dir migration.

- files: src/config.ts, src/session.ts, .env.example, README.md.

- risk: operators relying on hidden .runtime defaults may observe new default path; mitigated by env overrides and legacy session fallback.
- what: add sonnet 4.6 alias parsing/display support and align canonical model usage text in bot/help docs.
- why: keep runtime behavior and user-facing documentation consistent after the latest model change.
- files: README.md, src/handlers/commands.ts, src/session.ts.
- risk: low; touches model selection mapping/messages, with sonnet 4.5 backward-compat mapping retained.
- what: merge branch history into main while preserving current main file content after conflict resolution.
- why: keep branch lineage consolidated and reduce forgotten-branch risk while maintaining stable runtime-path behavior.
- files: merge commit only (no net file content changes).
- risk: low; validated with bun run typecheck.
- what: switch CODEX_APPROVAL_POLICY fallback/default from never to on-request

- why: allow privileged-command escalation flows by default instead of hard-locking codex threads

- files: src/config.ts, .env.example, README.md

- risk: low; behavior changes only when CODEX_APPROVAL_POLICY is unset or invalid

@linuz90 linuz90 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

A couple of things highlighted by Codex:

  1. The Claude reasoning behavior changed from keyword-triggered thinking to effectively always-on by default. That's a real latency/cost change, while the README still describes the old behavior. What's your reasoning here?
  2. The setup docs currently tell users to clone your fork instead of the upstream repo.

- what: changed CLAUDE_REASONING_EFFORT fallback/default to low, updated examples to low (opt-in medium/high), and switched setup clone URL to upstream repo

- why: address maintainer feedback by removing default always-on reasoning behavior and correcting fork-first setup instructions

- risk: low; only affects default behavior when env is unset/invalid and documentation examples
@artemgetmann

Copy link
Copy Markdown
Contributor Author

Thanks — both points are fair.\n\n1) Reasoning default:\nMy original intent was quality-first because output quality drops noticeably without reasoning in some workflows. But I agree default-on changes latency/cost expectations.\nI’ve now restored safe default behavior so reasoning is keyword-triggered by default, while medium/high remain explicit opt-in via config ().\n\n2) Setup docs:\nAgreed. I updated setup instructions to use the upstream repo (not my fork).\n\nFollow-up commit pushed to #6: b5a4863

@artemgetmann

Copy link
Copy Markdown
Contributor Author

Quick clarification (my previous comment had CLI formatting artifacts):

  • Reasoning is now keyword-triggered by default again.
  • Baseline always-on reasoning is opt-in via CLAUDE_REASONING_EFFORT=medium|high.
  • Setup docs now point to the upstream repo.

If this looks good now, happy for re-review on #6.

miracleengineered pushed a commit to miracleengineered/miracle that referenced this pull request Apr 22, 2026
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
期限超過45件(45%)を3カテゴリ振分=A候補(silently完了/陳腐化7件=bulk --done 候補)+B現役だが10日進んでない20件(取引先返答待ち9件+案件内残10件+内容不明3件)+C内部🦞stalled8件(うち4件=次tickで新規ファイル化可能=#76音声対話/#74Android/#68前職cdnt/#41 token答え合わせ)。朝queue +1。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
…装のfirst-time-right化(②削除は前tickで2重verified済so①専任)。MORNING-MASTER①小fix 9件を、静的doc記述と別軸=各fixのlocationを実機srcで直読(grep+sed)し「行番号一致・fix記述一致・バグクラス完全性」まで独立照合。★9件すべて記載locationにコード実在+記述一致=削除/追加GO。★MED級実バグ4件は挙動まで追跡し全てreal確定=linuz90#5 text.ts:200-222 AI Session Bridge分岐がreturn(L221)にstopProcessing()を持たず他4分岐+fallthroughは全て呼ぶ=唯一の_isProcessingリーク/linuz90#6 streaming.ts segment_end editMessageText成功(L257-259)後にlastContent.set漏れ→done footer(L322)がstale読取=末尾巻戻し(streaming編集L203/208は都度set済so非対称)/linuz90#7 callback.ts:88 mt:restore execSync(timeout15s)がasync handler内=bot最大15sフリーズ/linuz90#8 file-handler.ts:69 sips Bun.spawnSyncがevent loopブロック。★バグクラス完全性=startProcessing()呼出は全src3箇所(text.ts:170+document.ts:240,385)を実機確定→document.ts2件はtry/finally構造soリーク不能=#5が唯一の漏れ=churn防止claim正しい。★朝への申し送り1点(soft cross-dependency)=#8の「hot-path exec 3サイトのみ」完全性claimは②削除依存(media-commands.ts:96,299 spawnSyncは削除で消える)+image-handler.ts:90 spawnSyncが①単独完了時に宙に浮く=呼出元live判定を1grepで確認要(live=同fix/dead=②削除待ち)。read-only(grep/sed=書込なし)+新規doc1本(VERIFY-fix-batch-2026-07-09-1945.md)+log追記のみ・可逆commit(state配下のみ)。src編集/削除/typecheck変更/送信/settings/hook/launchd/gate緩和=ゼロ(実装は朝DJ判断)。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
…RNING-MASTER ①の linuz90#5(text.ts isProcessingリーク)/linuz90#6(streaming footer巻戻し)/linuz90#7(callback execSync)/linuz90#8(file-handler spawnSync) を working tree直読で機械照合=4件とも記述と一致=朝そのまま実装可。#8のみ実装nuance=Bun.spawn化時 proc.exitCode(async ではnull)→(await proc.exited)判定に書換え必須=単純 spawnSync→spawn 置換だと変換失敗に退行=VERIFY docに明記。read-only+新規doc1本+log追記の可逆commit(state配下のみ)。src編集/送信/削除/gate緩和=ゼロ。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
…ER ① の全9件を live code 8ファイル直読で before→after まで確定(#1 council L243/295/336=生replace→()=>関数形/linuz90#2 security L174=includes("rm ")→/\brm\s//linuz90#3 jarvis-memory L420=per-row safe-parse/linuz90#4 snooze L259-269=per-item try-catch+成功実数log/linuz90#5 text L221=stopProcessing()漏れ1行/linuz90#6 streaming L259=lastContent.set漏れ1行(ユーザー可視MED)/linuz90#7 callback L88=execSync同期→execAsync await化(bot15秒フリーズMED・execSync使用はL12importとL88のみと機械確認)/linuz90#8 file-handler L69=spawnSync→spawn+await proc.exited nuance明記/linuz90#9 callback L188=Number.isNaN前置)。各fixに現状行・反転test・完全性根拠を併記。read-only+新規doc1本+log。src編集/送信/削除/gate緩和=ゼロ。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
…inuz90#6=streaming.ts segment_end最終edit(L257-259)後のstate.lastContent.set漏れをstreaming途中edit(L200→L203 set)との非対称で確定+★FINAL未明示の読み側をend-to-end追跡=done footer付与(L316-320)がstale lastContent(L318)を読み末尾巻き戻す因果連鎖を実コードで裏取り(fix=L259直後1行・FINAL通り)。linuz90#7=callback.ts L88 execSync(timeout15000)がasync内=event loop最大15sfreeze確定。行番号drift0(doc-only commit群でsrc無変更)。read-only(sed/grep)+新規verify doc1本+log1行、src編集/削除/送信/settings/hook/gate緩和ゼロ。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
discord-integrity-check.py(毎日3:00・last-exit=0で"健全"表示)はliveness
検査(linuz90#4)をchannels.json.imsg_threads 1台帳に限定=case_threads_external/
internal・group・ハードコードIDが盲点=ID保持台帳の約1/5しか実在性を突かない
ため、M1312 Unknown Channel と dj-confirm …337223 の404を毎回沈黙で見逃した。

派生①(確定fix): DJ確認threadがsplit-brain。dead=…337223(cache-prune.jsonl
で2026-07-10 quarantine済)を dj-confirm-thread-learner.py:54 と inbox-mail-
ids.json が参照。live=…950262 は他4箇所(integrity-check/inbox-triage×2/
case-kb-auto-updater/channels.json)が使用=差替先は確認不要で確定。
派生②(候補): M1312も config内で external…281340(死) vs unified…310501 が
不一致=GET1回で正を確定。
判断⑩(俺推しYES): integrity#4を全ID台帳のliveness検査へ一般化=判断⑦類を
今後3:00 tickが自動surface(憲法linuz90#6 3回失敗→仕組み根治)。

read-only(grep+既存errlog+cache-prune.jsonl)+新規doc1本+朝queue1行=
src編集/送信/plist変更ゼロ=安全包絡線内。全fixは既存ファイル改修so朝DJ適用。
DAIJIROMATSUOKA pushed a commit to DAIJIROMATSUOKA/claude-telegram-bot that referenced this pull request Jul 12, 2026
…のみ壊れ・残11本安全)

直近3ticksの単発発見を憲法linuz90#6+全ソース機械列挙に従い全数監査。
/usr/bin/python3指すplist14本→AST import抽出+system py3実importテスト+.err裏取り。
壊れ3本(gmail-case-rawlog/order-received-auto=hard crash・kb-tag-indexer=silent)で確定。
残11本stdlib安全=変更不要。朝queueに一括fix+lint仕組み化+生成テンプレ調査を推奨。
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