chore(gastown): remove manual request logging middleware#3158
Open
jrf0110 wants to merge 3 commits intogastown-stagingfrom
Open
chore(gastown): remove manual request logging middleware#3158jrf0110 wants to merge 3 commits intogastown-stagingfrom
jrf0110 wants to merge 3 commits intogastown-stagingfrom
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This is a clean deletion of redundant request-logging middleware. The removed code:
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-4.6 · 220,254 tokens |
jrf0110
commented
May 10, 2026
Comment on lines
-193
to
-198
| logger.setTags({ | ||
| orgId: RE_ORG.exec(path)?.groups?.orgId, | ||
| townId: RE_TOWN.exec(path)?.groups?.townId, | ||
| rigId: RE_RIG.exec(path)?.groups?.rigId, | ||
| agentId: RE_AGENT.exec(path)?.groups?.agentId, | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
It'd still be nice to set tags on requests, but maybe we can do it in a way more structured way like:
app.use('/api/towns/:townId', async (c, next) => {
logger.setTags({ townId: c.req.param('townId' })
await next()
})…ayor tools on prewarm Three independent fixes for the startAgentInContainer timeout regression introduced by #2974, plus a tighter container-instance cap. 1. Hydration gate (control-server.ts, process-manager.ts) The control server starts accepting requests immediately at boot, while bootHydration runs concurrently and serialises every registry agent + the mayor prewarm through the global sdkServerLock. Fresh /agents/start, /refresh-token, and PATCH /agents/:id/model requests queued behind that work and the DO-side AbortSignal.timeout(60s) fired before they ever got the lock — surfacing as "TimeoutError: aborted due to timeout" and "timeout after 6000ms: ensureSDKServer for <agentId>". A new awaitHydration() promise is awaited at the top of those handlers (before any process.env mutation in the model PATCH path) so they don't compound the queue. 2. Prewarm config matches /agents/start (Town.do.ts, gastown.worker.ts, process-manager.ts) buildPrewarmEnv was constructing KILO_CONFIG_CONTENT from hardcoded defaults (anthropic/claude-sonnet-4.6 / claude-haiku-4.5), so the real /agents/start with the user's actual model triggered ensureSDKServer's "config mismatch, evicting prewarmed server" path on every warm restart — doubling lock-holding time on the critical path the prewarm was supposed to speed up. The /api/towns/:id/mayor-id endpoint now returns the full prewarm context (model, smallModel, kilocodeToken, organizationId) resolved the same way _ensureMayor resolves it, and the container builds the prewarm KILO_CONFIG_CONTENT to match. Falls back gracefully to a skip when the worker hasn't deployed the richer endpoint yet. 3. Mayor workdir + plugin env (agent-runner.ts, process-manager.ts) prewarmMayorSDK called mayorWorkdirForTown (which only returns a string) and went straight to ensureSDKServer's process.chdir, throwing ENOENT on cold containers because createMayorWorkspace only ran from runAgent. Exported ensureMayorWorkspaceForTown so prewarm materialises the workspace first. More critically, buildPrewarmEnv was missing GASTOWN_AGENT_ROLE, GASTOWN_AGENT_ID, and GASTOWN_TOWN_ID — env vars the kilo serve plugin (plugin/index.ts) reads at spawn to decide whether to register mayor tools. Without them the prewarmed server booted with NO mayor tools, and the cache hit on the next /agents/start handed that defective instance back to the user. Now mirrors the mayor- shaped subset of buildAgentEnv. Added an end-to-end test that intercepts createKilo and asserts the env at spawn time. 4. wrangler.jsonc: lower TownContainerDO max_instances from 800 to 500. Verified with pnpm --filter gastown-container test (67/67 pass), pnpm --filter cloudflare-gastown typecheck, oxlint, and pnpm format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the redundant request-logging middleware from
gastown.worker.tsthat logged every HTTP request twice (incoming + outgoing) vialogger.info(). This is already covered by the per-routeinstrumented(c, route, handler)wrapper fromanalytics.middleware.tswhich emits structured AE events withroute,userId,townId,rigId,agentId,beadId,durationMs, anderrorfor every wrapped route.Two pieces removed:
import { logger } from './util/log.util'line (now unused at the worker level)app.use('*', ...)withlogger.setTags,logger.infocalls)Preserved:
timingMiddlewareanduseWorkersLoggermiddleware — these are independent infrastructure that other code depends on.Verification
Manual review of the diff confirms 30 lines deleted, 0 added, single file modified.
Visual Changes
N/A
Reviewer Notes
The
logger.setTagscall from URL regexes is safe to remove — those tags were only consumed by the twologger.infolines being removed. Auth middleware already setsorgId/userIdtags via JWT-derived values. Town.do.ts runs in a separate isolate and does its ownsetTags.