𝗠𝘆 𝗖𝗼𝗱𝗶𝗻𝗴 𝗔𝗴𝗲𝗻𝘁 𝗙𝗶𝗻𝗶𝘀𝗵𝗲𝗱 𝗧𝗵𝗲 𝗧𝗮𝘀𝗸. 𝗪𝗵𝘆 𝗗𝗶𝗱 𝗧𝗵𝗲 𝗧𝗵𝗿𝗲𝗮𝗱 𝗗𝗶𝗲?
The worst bug in a coding agent is not a crash.
It is when the first task succeeds but the next message feels like amnesia. You ask for a task. The agent finishes. Then you say: "make the button green."
To you, this is the same conversation. To the system, a completed task often means the session is over. The system starts from scratch.
While building CliGate, I realized I mixed three different layers:
- The chat conversation
- The runtime session
- The current execution turn
These are not the same thing.
A conversation is a long-lived space for talking. A runtime session is the working thread for that conversation. A turn is one single run inside that session.
When a task completes, only the turn should end. The session must stay active.
The broken flow looks like this: User asks for a task -> Runtime session starts -> Task completes -> Conversation clears the active session -> Next follow-up starts a brand-new session.
This breaks short follow-ups like:
- retry that
- do the same for this file
- explain the error
- continue
If the system detaches the session immediately, you must restate everything. The agent works, but the conversation feels fake.
I fixed this by making the model explicit:
- Conversations are persistent.
- Runtime sessions are sticky by default.
- Completed or failed tasks only close the current turn.
- New sessions only start if the user asks or if the model changes.
I stopped treating task completion as session death. This tiny change improves the entire product feel.
In CliGate, a new session only starts if:
- There is no session yet.
- The user asks for a new one.
- The model change makes the old session incompatible.
This matches how humans think. A user expects one chat tab to act like one ongoing thread. This is vital on mobile apps like Telegram or Feishu.
The new logic is simple:
- The first message creates a runtime session.
- Later messages keep using that session.
- Completion does not drop the thread.
- Only explicit commands start a fresh session.
This makes the agent feel like a coworker rather than a command launcher.
If you build coding agents, remember this: The conversation is the durable unit. The runtime session is the reusable worker. The turn is the thing that ends on success or failure.
이 세 가지 레이어를 분리하세요. 그러면 후속 대화가 마침내 자연스럽게 느껴질 것입니다.
출처: https://dev.to/codekingai/my-coding-agent-finished-the-task-why-did-the-thread-die-2jk2
선택 사항 학습 커뮤니티: https://t.me/GyaanSetuAi