All MicroEvals
frontend mar kesz neked azzal nincsen dolgod csak a main.py-...
Create MicroEval

frontend mar kesz neked azzal nincsen dolgod csak a main.py-...

Prompt

frontend mar kesz neked azzal nincsen dolgod csak a main.py-t ird meg! Send back the complete code with all the fixes. Fix each of the listed errors one by one, making sure to actually correct them so that there are 0 errors remaining. Keep the original imports, since the files exist. Write out every single character; do not abbreviate anything. Fix every error. There must be exactly one file. Do not write anything else; just output the complete code, and it must not contain any comments. Never, under any circumstances, use simplified, substitute, dummy, simulated, or fake code. Write the entire file as complete, unabridged, production-ready code in a single code block. It must be 100% error-free, a complete, error-free file, and must be submitted as a downloadable file. These requirements are mandatory and must be strictly adhered to. If no list of errors is provided, you must find all the errors and fix them. If there were comments in the original code, delete them. And most importantly: YOU MUST NEVER SIMPLIFY! import os from google import genai client = genai.Client( api_key=os.environ.get("GEMINI_API_KEY"), ) tools = [ { 'type': 'code_execution', }, ] generation_config = { 'max_output_tokens': 65536, 'thinking_level': 'high', } interaction = client.interactions.create( model='models/gemini-3.8-flash', input="""INSERT_INPUT_HERE""", system_instruction='használd a code executeuont', tools=tools, generation_config=generation_config, ) print(interaction.steps[-1]) @chat.html a frontend The backend must always be implemented in a single file, and the frontend must always be contained in a single index.html file, including all subpages. backendbe ezr a modelt es igy integrald frontenden ha a CoT komponenst kinyitom ott lathato legyen a gondolkozas es a code futtatasok ha meg akad mert mondjuk tool limit eleri akkor a vackend automatikusan kuldjon uzenetet a modelnek hogy "An unexpected error occurred. Resume the interrupted task and finish the remaining work. " de ezt frontenden ne mutassa Build Prompt: Durable Decoupled Asynchronous Agent Task System Build a complete, production-ready web system from scratch. The system must execute long-running AI agent tasks independently of the browser HTTP request, persist every progress step as an ordered event stream, and allow a client to disconnect, close the tab, lose network, reopen the page, and resume streaming exactly where it left off. The worker must continue running even when no client is connected. Do not include authentication, authorization, access control, security policies, auditing, monitoring, rate limits, usage limits, quotas, billing, payments, tests, documentation, source comments, configuration comments, placeholder code, mock implementations, dummy services, fake services, TODO markers, unimplemented methods, or omitted files or functions. Implement every behavior described below fully. 1. Core Architectural Goal The system must not perform AI generation inside the lifetime of the initial HTTP request. Instead: 1. The client submits a chat task through an HTTP endpoint. 2. The server immediately creates a durable job record in the database with status queued. 3. The server invokes a database RPC that starts an independent background worker process. 4. The HTTP request returns promptly with the job identifier. 5. The client opens a Server-Sent Events connection and reads job events from the database. 6. The background worker performs AI reasoning, tool invocation, code execution, and all other task work. 7. Every worker step is appended as an immutable event to a database event table. 8. The worker renews a time-limited lease on a fixed interval to prove it is alive. 9. If the client disconnects, the worker keeps running. 10. When the client returns, it discovers running jobs, determines the last event it received, fetches missed events, and resumes live streaming. The architecture must support tasks that run for minutes or hours without being terminated by HTTP timeouts. 2. Required Technology Shape Use: - A relational database with two core tables and one RPC function. - An HTTP server exposing task submission, task synchronization, and SSE streaming endpoints. - A standalone background worker process responsible for executing jobs. - An event sink abstraction used by the worker to append events to the database. The worker must be decoupled from the HTTP request lifecycle. The SSE connection must only read stored events and must not be the execution channel. 3. Database Schema 3.1 Table: agent_jobs Create a table named agent_jobs with at least the following columns: - id: unique job identifier, primary key. - status: text, required. Allowed values: - queued - running - completed - failed - input_payload: text or JSON, containing the user message and all task input data. - lease_expires_at: timestamp, nullable. Defines the current worker ownership lease. - created_at: timestamp, required. - started_at: timestamp, nullable. - finished_at: timestamp, nullable. - final_result: text or JSON, nullable. - error_message: text, nullable. Required behavior: - A new job is inserted as queued. - When a worker acquires the job, status becomes running and lease_expires_at is set to 90 seconds in the future. - Heartbeat updates extend lease_expires_at. - On successful completion, status becomes completed, finished_at is set, and final_result is stored. - On failure, status becomes failed, finished_at is set, and error_message is stored. 3.2 Table: agent_job_events Create an append-only table named agent_job_events with at least: - id: monotonically increasing event identifier, primary key. - job_id: foreign key referencing agent_jobs.id. - event_type: text, required. - event_payload: JSON or text, required. - created_at: timestamp, required. Events must be immutable once inserted. Never update or delete events. Required event types include: - job_started - agent_thought - assistant_text_delta - tool_call_started - tool_call_output - code_execution_started - code_execution_output - progress_update - job_completed - job_failed Every meaningful worker action must produce one event. Events must be ordered by id. Reconnection must use the last received event id as the resume cursor. 3.3 Database RPC: kick_agent_worker Create a database RPC function named kick_agent_worker. Behavior: - It is called after a new queued job is inserted. - It triggers or wakes an independent background worker process. - It must not block until the job finishes. - It must return quickly to the caller. - It must ensure the worker can begin processing the queued job. The worker process must run outside the HTTP request context. Implement the HTTP server. Required endpoints: POST /api/agent-task Request contains the user message and task input. Behavior: 1. Validate the incoming task input. 2. Insert a row into agent_jobs with status queued. 3. Call kick_agent_worker through the database RPC. 4. Return the new job identifier immediately. 5. Do not perform AI generation in this handler. GET /api/agent-tasks/sync Returns the current client-relevant job state. Behavior: 1. Return jobs with statuses queued, running, completed, and failed. 2. Include each job identifier, status, timestamps, and final result when available. 3. The frontend uses this endpoint on page load to discover jobs that continued running while the page was closed. GET /api/agent-task/:jobId/stream This is the SSE endpoint. Behavior: 1. Set response headers for text/event-stream. 2. Accept a resume cursor representing the last event identifier already seen by the client. 3. Query agent_job_events for events with id greater than the cursor and matching the job. 4. Send all missed events first, in ascending order. 5. Keep the connection open and continue sending newly appended events as they become available. 6. Every SSE message must include the numeric event id. 7. When the job reaches completed or failed, send the terminal event and close the stream cleanly. 8. This endpoint must only read events; it must not execute agent work. Implement server-side job dispatch and streaming logic. Required functions: dispatchAgentJob(jobId) Behavior: 1. Receive the identifier of a queued job. 2. Invoke the kick_agent_worker database RPC. 3. Return after dispatch; do not await full job execution. followAgentJob(jobId, lastEventId, sendSseEvent) Behavior: 1. Read all events for the job with id > lastEventId. 2. Deliver them in strict ascending order. 3. Poll or subscribe for new events and deliver them live. 4. Continue until the job is terminal. 5. Preserve ordering under all circumstances. Implement the standalone background worker. Required function: executeAgentJob(jobId) Behavior: 1. Acquire the job by setting status to running and lease_expires_at to 90 seconds from acquisition. 2. Start a heartbeat interval. 3. Load the job input. 4. Run the full agent execution pipeline: - AI reasoning - assistant text generation - tool calls - code execution - any other agent actions 5. Append every step as an event through the event sink. 6. On success: - append job_completed - set job status to completed - store final result - set finished_at - clear the heartbeat interval 7. On failure: - append job_failed - set job status to failed - store error message - set finished_at - clear the heartbeat interval The worker must continue executing if the, SSE connection, or network client disappears. Implement lease heartbeat management. Required behavior: - Use setInterval with a 20-second interval. - On every tick, update agent_jobs.lease_expires_at to 90 seconds in the future. - Start the interval after job acquisition. - Stop the interval when the job completes, fails, or is intentionally terminated. - While the lease keeps being renewed, the job is considered alive. - The heartbeat is tied to the worker process, not to the client connection. 4.5 agent-job-event-sink.ts Implement the event sink. Required function: send(eventType, eventPayload) Behavior: 1. Append a new row to agent_job_events. 2. Associate the row with the current job. 3. Store the event type and payload. 4. Return the generated event identifier. 6. The database event table is the single source of truth for streaming and replay. Implement the actual agent execution logic. Required behavior: - Process the user task. - Produce assistant text increments. - Execute tools. - Execute code when required. - Emit an event before or after each meaningful action. - Return a final result. All intermediate output must go through the event sink. Implement all client-side logic. Required functions: submitTask(userInput) Behavior: 1. Send POST /api/agent-task. 2. Receive the job identifier. 3. Begin following the job. followJob(jobId, lastEventId) Behavior: 1. Open an SSE connection to /api/agent-task/:jobId/stream. 2. Pass the last seen event identifier as the resume cursor. 3. Process events in order. 4. Update the stored last event identifier after each rendered event. 5. Render each event type appropriately. 6. Stop when a terminal event is received. syncWithBackend() Behavior: 1. Call GET /api/agent-tasks/sync on page load. 2. Find jobs with status running. 3. For each running job, read the locally stored last_event_id. 4. Call restoreWorkTask(jobId, lastEventId). restoreWorkTask(jobId, lastEventId) Behavior: 1. Reconnect to the SSE stream for the job. 2. Download and render all events produced while the client was disconnected. 3. Continue live streaming from the exact point after the last seen event. 4. Resume the UI without losing prior output. The client must treat the database event log as the authoritative replay source. 6. End-to-End Required Flow 6.1 Submission 1. User sends a message. 2. Server inserts a queued job. 3. Server calls kick_agent_worker. 4. Server returns job id. 5. Client opens SSE stream. 6.2 Worker Execution 1. Worker acquires the job. 2. Job becomes running. 3. Lease is set to 90 seconds. 4. Heartbeat renews the lease every 20 seconds. 5. Worker appends events for every action. 6. SSE endpoint reads those events and forwards them to connected clients. 6.3 Disconnection If the browser tab is closed or network is lost: - The SSE connection drops. - The HTTP client disappears. - The worker does not stop. - The heartbeat continues. - Events continue being appended to agent_job_events. 6.4 Reconnection 1. User reopens the page. 2. syncWithBackend() loads jobs. 3. Client finds the still-running job. 4. Client reads its stored last event id. 5. restoreWorkTask() reconnects. 6. Missed events are fetched and rendered. 7. Live streaming resumes. 6.5 Completion 1. Worker finishes the task. 2. Appends job_completed. 3. Sets job status to completed. 4. Stops heartbeat. 5. SSE endpoint sends terminal event and closes. 7. Timing Constants Implement exactly: - Worker lease duration: 90 seconds. - Heartbeat interval: 20 seconds. The lease must be extended on every heartbeat while the worker is alive. 8. Event Sourcing Rules - The event table is append-only. - Events are the only mechanism for streaming progress. - The worker must not push directly to browser connections. - The SSE layer must read from the event table. - Reconnection must replay events by numeric event id. - No event may be omitted, abbreviated, or merged in a way that loses worker behavior. - Event ordering must be strictly preserved.

Drag to resize

Response not available

Drag to resize

Response not available

Drag to resize
Drag to resize
Drag to resize