Skip to content

Add automatic Thread naming source flow#263

Merged
crazygo merged 6 commits into
mainfrom
codex/thread-auto-name-source
May 25, 2026
Merged

Add automatic Thread naming source flow#263
crazygo merged 6 commits into
mainfrom
codex/thread-auto-name-source

Conversation

@crazygo
Copy link
Copy Markdown
Collaborator

@crazygo crazygo commented May 21, 2026

Summary

  • add chat_channel_names source metadata and generated-name attempt tracking
  • auto-name non-main Threads from the first user message, then generate/fallback a title once after successful replies
  • raise default agent-loop tool-call budget from 10 to 50
  • add evidence-case-loop harness for Thread auto naming

Validation

  • cd apps/node_backend && npm test -- src/routes/chat.test.ts src/services/localAgentLoopService.test.ts src/llm/llm_service.test.ts src/db/migrate.test.ts
  • cd apps/node_backend && npm run type-check
  • npx js-yaml docs/code_maps/feature_map.yaml >/dev/null && npx js-yaml docs/code_maps/logic_map.yaml >/dev/null
  • git diff --check
  • PORT=3023 BRICKS_API_BASE_URL=http://127.0.0.1:3023 tools/evidence/thread_auto_name_source/run.sh

Evidence

  • .cache/evidence/thread-auto-name-source/20260522-000925/summary.json

Copilot AI review requested due to automatic review settings May 21, 2026 16:13
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bricks Ready Ready Preview, Comment May 25, 2026 10:08am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces automatic naming for non-main chat Threads by recording name provenance in chat_channel_names, inserting an initial name from the first user message, then attempting a single generated title after a successful assistant reply. It also increases the default agent-loop tool-call budget and adds an evidence harness to validate the end-to-end flow.

Changes:

  • Add source + generated_name_attempted_at to chat_channel_names, plus service helpers to insert/claim/complete auto thread names.
  • Implement the auto-naming flow in /api/chat/respond (insert exact name early; generate/complete one title after successful completion).
  • Raise default agent-loop maxToolCalls from 10 to 50 and add an evidence case harness to validate behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tools/evidence/thread_auto_name_source/thread_auto_name_flow.mjs New evidence flow script that drives /api/chat/respond and validates naming via DB checkpoints.
tools/evidence/thread_auto_name_source/run.sh Harness runner that loads .env.local, optionally migrates/starts backend, and executes the evidence flow.
tools/evidence/thread_auto_name_source/AGENTS.md Evidence-case documentation describing requirements, checkpoints, and how to run the harness.
docs/plans/2026-05-21-19-57-CST-thread-auto-name-source.md Plan doc for thread auto-name source tracking and rollout steps.
docs/plans/2026-05-21-16-43-CST-agent-loop-limit-empty-final.md Updates plan to reflect increased default tool-call budget.
docs/code_maps/logic_map.yaml Adds migration reference and documents new auto-thread naming constraints + new tool-call budget.
docs/code_maps/feature_map.yaml Documents the new thread auto-naming behavior and updated agent-loop budget.
apps/node_backend/src/services/chatChannelNameService.ts Adds source/attempt fields and new helpers for the exact/claim/complete auto-naming workflow.
apps/node_backend/src/routes/chat.ts Implements auto thread naming during async respond flow; increases default tool-call budget and request max.
apps/node_backend/src/routes/chat.test.ts Updates tests for new tool-call default and adds coverage for the thread auto-naming flow.
apps/node_backend/src/db/migrations/020_chat_channel_name_source.sql Adds source and generated_name_attempted_at columns to chat_channel_names.
Comments suppressed due to low confidence (1)

tools/evidence/thread_auto_name_source/AGENTS.md:99

  • AGENTS.md says the generatedNameVisible checkpoint verifies that “/api/chat/channel-names shows first_message_generated”, but the harness actually polls the database (chat_channel_names) directly and does not call /api/chat/channel-names. Update the checkpoint description to match what the script does so readers know where to look when debugging failures.
## Checkpoints

- `authMe`: test token resolves to the expected fixture user.
- `backendReady`: local backend responds on `/api/health`.
- `baselineNoName`: the generated fixture Thread has no name row before the flow.
- `firstRespondAccepted`: `/api/chat/respond` accepts the first message.
- `generatedNameVisible`: `/api/chat/channel-names` shows `first_message_generated`.
- `secondRespondAccepted`: a second message is accepted in the same Thread.
- `generationRunsOnce`: source/name/attempt timestamp do not change after the second message.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/node_backend/src/services/chatChannelNameService.ts Outdated
Comment thread apps/node_backend/src/services/chatChannelNameService.ts
Comment thread apps/node_backend/src/routes/chat.ts Outdated
Comment thread tools/evidence/thread_auto_name_source/thread_auto_name_flow.mjs Outdated
Comment on lines +48 to +60
required_vars=(
BRICKS_TEST_TOKEN
FIXTURE_USER_ID
JWT_SECRET
BRICKS_API_BASE_URL
)

for name in "${required_vars[@]}"; do
if [[ -z "${!name:-}" ]]; then
echo "Missing required env var: $name" >&2
exit 1
fi
done
Comment thread apps/node_backend/src/routes/chat.ts Outdated
Comment on lines +18 to +24
Before a respond request, the case-specific `channelId + threadId` must have no
name row in `/api/chat/channel-names`.

## Fixed Behavior To Prove

After the first respond request completes, using API for the user action and DB
checks for low-request evidence:
crazygo and others added 5 commits May 25, 2026 17:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@crazygo crazygo merged commit b114db6 into main May 25, 2026
9 of 11 checks passed
@crazygo crazygo deleted the codex/thread-auto-name-source branch May 25, 2026 10:21
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