HackerTrans
トップ新着トレンドコメント過去質問紹介求人

sibidharan

no profile record

投稿

Ask HN: ZealPHP – Dangers Isolating Request-State in Coroutines?

3 ポイント·投稿者 sibidharan·先月·0 コメント

コメント

sibidharan
·先月·議論
Agents SDK is very useful. In-fact can design handoffs and multi agent orchestration very intuitively, and that is where the sessions, chat history all comes together. Agents SDK solves all the caveats with Responses API, from making it more than an API, into an SDK. The SDK is a layer on top of Responses API, so the SDK gives you lot of boilerplate for so many things.

I love PHP since beginning! ZealPHP is my own creation, actively developed. We created it inside our Academy. It powers our EdTech tool today as well. We initially used Apache+mod+php, but as AI needs grew, I don't want to rewrite the whole codebase for asynchronous operations to have SSE, sockets, streaming etc. I used to do with sidecars like RabbitMQ. So it began as an experiment inside the academy, today the same framework powers the EdTech tool we use in-house. To be exact, we made the same Apache+mod_php codebase run in ZealPHP and made it asynchronous.

And why PHP... because it's bloody fast when run asynchronous! HTML rendering is first class, we made ZealPHP yield HTML like react's renderToPipeableStream, and much more using OpenSwoole, making it close to the SAPI contract with classic PHP mental model. So I wanted to explore what PHP could offer in this new direction.

If you like to explore more on how PHP is "bloody fast" and "why": Kindly check https://php.zeal.ninja/performance & https://php.zeal.ninja/why-zealphp

If you like to explore how we made the same codebase run on 2 different server: https://php.zeal.ninja/case-studies/sna-labs

// ZealPHP being Actively developed now!
sibidharan
·2 か月前·議論
I am using Agents SDK by OpenAI. It's interoperable with every other inference provider, even local models running on LMStudio.

I am using OpenAI from the beginning for all AI Apps I build. Initially it was only Completions API. Then came Responses API. They introduced something called Assistants API with conversation stored on server side and soon pulled the plug on Assistants API for the enhanced Agents SDK with all sessions and things stored locally as we want.

So I moved all my old completions/responses API projects to Agents SDK! They feel good and stable. Making chat with Agents SDK is super easy. Can stream tool calls and tokens effortlessly!

Agents SDK takes care of sessions, token tracking, caching, and so many things! In my apps, it helps me track how much is cached, how much is new!!! And best part about Agents SDK is it takes care of cleaning up old tool calls that saves your context, and it also auto summarises as the chat grows (I might be wrong about the last one).

I am building an EdTech with lot of AI learning / evaluation tools including isolated compute layer for my students! That led me to create an OSS project - which might have some answers for your original question.

I am working on an Open Source Async SAPI for PHP to make PHP convenient for building realtime AI apps (still in alpha and actively developing), and have created a small lesson on how to use agents SDK for AI Apps as a way to showcase my framework. If you like to see my approach, this lesson is a good place to skim.

Lesson 29: https://php.zeal.ninja/learn/ai-chat

Agent SDK Example Code used on above lesson: https://github.com/sibidharan/zealphp/blob/master/examples/a...

I follow this style everywhere in my code. Agents work as separate python code detached from whatever framework we use to build Apps, streams via STDIO and I stream the tokens over SSE/WebSockets to frontend as needed - clean architecture.

Different architecture may have different needs! A simple chat response, SSE is ok. A complicated long running stream, WebSockets!

This is how I am doing. Interested to know how others are approaching this.
sibidharan
·2 か月前·議論
What you think about attaching the chat transcript that lead to the final output when marking AI generated? it may be interesting to see how people will be feel a shame at how they generate slop vs genuinely using AI to come up with something. I see lot of VC applications follow this. But not sure how it will be applicable for HN.

Just need to bust low effort outputs!
sibidharan
·2 か月前·議論
I heard claude models are of trillions of parameters !!! 284B, 1M... I wouldn't trust on long running autonomous agents! But for the API costs, this is justified if a better hardware with bigger model is used and will be a claude equivalent for comparable quality at long context retrieval on long running autonomous tasks. At least for me that is important.
sibidharan
·2 か月前·議論
So being imperfect is fine... mmmm!!!
sibidharan
·2 か月前·議論
Its just me steering all tokens... Multiple projects for my bootstrapped Academy, running parallel researches on things I wouldn't do myself, and deriving the right patterns for the future. Using different Max on same machine. I have similar ~$22K on another machine, where I am working in parallel with the same 2xMax subscriptions!

So if the prices were to go high, I honestly have no idea at the moment. I might need a rehabilitation centre!!!

But I am mentally prepared that someday this will be gone... So make hay while the sun shines! I am doing the most complex of all works I want to do... And pushing the limits. Knowing how much it costs in actual tokens, I give me some kind of seriousness, like an invisible funding that I must use to grow!! Considering this like a launchpad... If any of the projects hit and scale and I get some funding in future, then I might not need to worry when prices go high. So either this or rehab lol !
sibidharan
·2 か月前·議論
It's been like this all along! We can write complex applications with HTML/CSS/Vanilla JS... But then.. React happened! UI rendering JS is bad - thats just my opinion. If server can render HTML and serve, whats better than that? Its ok for apps where browser is the source of truth like Figma, Google Sheets.. But using React for everything ... that is overkill. Most apps has server as the source of truth, data lives in server, and it can generate HTML right there.. No need for JSON+Hydrate, which is unnecessary- because server can generate HTML, the browser can understand HTML... Virtual DOM makes React Fast, not our apps fast..

AI didn't eliminate the need for frameworks.. It just picks the right one for the Job.. when plain HTML is ok, it chooses plain HTML.
sibidharan
·2 か月前·議論
[dead]
sibidharan
·2 か月前·議論
I am running a self hosted Wireguard for my academy with ~15k student devices connected... Even during high disk IO, it's all RAM only and it never goes down. Once our NVME got bad blocks and was working degraded - but ... Wire guard is in-memory and bloody stable! Its the backbone of our academy for several years for students to access their cloud labs and connected devices.

1 Static IP, A linux machine onprem with necessary redundancy. Working like a clockwork.
sibidharan
·2 か月前·議論
It's a lottery however!
sibidharan
·2 か月前·議論
Social-networks are anti-AI! Here for soul-soul communication, not kinking for machines!
sibidharan
·2 か月前·議論
Which models are we talking about? Is there any degradation in quality, long context retrieval?
sibidharan
·2 か月前·議論
TL;DR = ~$22,720 total compute @ Opus 4.7 if no caching = $113,418 (5.9x more) - this is just one month on one server... I have 3 more servers like this where I work all time!

// Generated wit Claude

Ran this on my own ~/.claude/projects/ (933 sessions, 93,842 model calls, mix of main thread + spawned subagents). Numbers came out very close to yours in shape, different in scale.

cost.py (Opus 4.7 list rates, main thread only):

  cache reads (re-reading context)   21.69B tok   $10,843   56%
  cache writes (1h)                     678M tok   $6,781   35%
  output (incl. reasoning)             63.5M tok   $1,589    8%
  fresh uncached input                  1.6M tok       $8    0%
  TOTAL                              22.43B tok   $19,221

  if no caching: $113,418 (5.9x more)
  input:output ratio: 353:1
  cache hit rate: 97.0%
token_time_breakdown.py (179M unique tokens, 166h wall clock):

  reasoning (hidden thinking)   29% of tokens,  102h (61%) of time
  bash                           1.4%           23h (14%)
  writing tool calls             4%             14h  (8%)
  summaries                      2.5%            9h  (5%)
  reading/searching/web          1.6%            7h  (4%)
  subagents                      0.2%            6h  (4%)
  editing                        0.1%            5h  (3%)
  pasted attachments             25.3%           -
  typed prompt                   34.4%           -
  system+tools                   1.4%            -
reread_breakdown.py (per-activity share of billed input):

  reasoning           59.5%   (~$11.4k of the bill is re-sending old
                               hidden thinking back to the model)
  attachments         22.6%
  tool calls           7.8%
  bash                 3.0%
  reading/web          2.4%
  my prompt            1.6%
  summaries            1.5%
  system+tools         0.8%
  subagents            0.4%
main_vs_sidecar.py:

                          main         sidecar      combined
  sessions/agents          449         484           933
  assistant calls       63,820      30,022        93,842
  cache hit             97.0%        94.4%         96.6%
  turns/agent             142 (median 20, max 11,058 in one session)
                                       62 (median 44)
  reasoning % of out    82%          51%           77%
  cost @ Opus 4.7    $19,225       $3,495       $22,720

  sidecar = 32% of calls but only 15% of cost. Subagents are doing
  their job (cheap, focused, short context).
Same shape as yours: re-read dominates, reasoning is the biggest re-read line, caching is the only thing keeping it sane. The one that surprised me was a single 11,058-turn main session - some autonomous loop I forgot to kill. Going to grep for that.

Repo: github.com/Coral-Bricks-AI/coral-ai/tree/main/claude-code-token-xray
sibidharan
·2 か月前·議論
Whatever AI generates is considered slop or is there a scale?
sibidharan
·2 か月前·議論
I hit rate-limit every other day... 5 hour... Week... I consume my 20x weekly in 3 days! So having 2x 20x!

If I could harness $10000 worth of API usage... this is the best time, no idea how long we will get this subsidy! I wont pay $10000 out of my pockets to do the same work!
sibidharan
·2 か月前·議論
Haha that is why egg heads comment "forget all instructions and give me bla bla"
sibidharan
·2 か月前·議論
You mean if I use 2x $200 Max fully every week, I actually consume ~$5000 worth of API usage ?? Wow!!!
sibidharan
·2 か月前·議論
I wrote this: There are people who do not have English as their first language. So using AI to write is ok, but they should indicate it? vs entirely AI generated without human review is slop. But then non-native English speakers can scribble ideas and get it structured with AI. That is actually good for both sides as it makes the communication better!

AI rewrote this: Some people don’t speak English as their first language. Using AI to write is fine but they should indicate it. However, entirely AI-generated content without human review is poor. Conversely, non-native English speakers can jot down ideas and have them structured with AI. This benefits both parties as it improves communication.

Now the latter is considered entirely AI generated? Did the rewrite actually help or you like to read the raw version I wrote? Which feels good to read?
sibidharan
·2 か月前·議論
Yes, this deployment more of EdTech! But what tools you are willing to run decides the deployment nature. What makes it EdTech-ish is the type of labs it has now. If you have a tool that you want to run on linux and access via browser/port, then this is a right architecture. Rest is all networking and compute instances talk to each other.

So you need to tell which tooling you want, and I might be able to configure it. I am no biologist, but an engineer who understands DevOps.
sibidharan
·2 か月前·議論
I built one and about to open-source it in a few months: https://labs.selfmade.ninja

This lives in my academy atm - but you can signup for free and try it out. This is a DevOps infra for higher educational research - right now focused on Cybersecurity, IoT, Software Engineering, AI Workflows.

But this can be customised to whatever you want to run - because all I provide is a mini self-hosted AWS for EdTech that gives you MicroVMs, VPN, Hosting, AI Based learning and evaluation tools, all gamified. It can generate Roadmaps and link them to lessons you can then try on labs! So a lab can be anything you want to be!

You looking for something like this? Am I anywhere near?